当前位置: 首页 > news >正文

php网站开发 实战教程品牌vi包括什么

php网站开发 实战教程,品牌vi包括什么,做柜子设计的网站设计,长沙建设银行招聘网站目录 1.next_permutation函数的定义 2.简单使用 2.1普通数组全排列 2.2结构体全排列 2.3string 3.补充 1.next_permutation函数的定义 next_permutation函数会按照字母表顺序生成给定序列的下一个较大的排列,直到整个序列为降序为止。与其相对的还有一个函数—…

目录

1.next_permutation函数的定义

2.简单使用

2.1普通数组全排列

 2.2结构体全排列

2.3string

3.补充


1.next_permutation函数的定义

next_permutation函数会按照字母表顺序生成给定序列的下一个较大的排列,直到整个序列为降序为止。与其相对的还有一个函数——prev_permutation函数。

next_permutaion(起始地址,末尾地址+1)
next_permutaion(起始地址,末尾地址+1,自定义排序)

注:next_permutation只能获得上一个排列,如果要获得全排列,那么就需要先对数组进行升序排序

2.简单使用

2.1普通数组全排列

#define _CRT_SECURE_NO_WARNINGS 1#include <iostream>
#include <algorithm>
using namespace std;int main()
{int arr[4] = { 1, 2, 3, 4 };do {for (int i = 0; i < 4; i++){cout << arr[i] << " ";}cout << endl;} while (next_permutation(arr, arr + 4));return 0;
}

 运行结果:

1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1

 2.2结构体全排列

由于结构体默认不能比较大小,所以就不能使用默认的next_permutation()排列比较函数,需要使用自定义排列比较函数。

#define _CRT_SECURE_NO_WARNINGS 1#include <iostream>
#include <algorithm>
using namespace std;typedef struct
{int test;bool operator < (const fyd& a){return test < a.test;}}fyd;fyd arr[4];int main()
{arr[0].test = 2;arr[1].test = 1;arr[2].test = 4;arr[3].test = 3;do {for (int i = 0; i < 4; i++){cout << arr[i].test << " ";}cout << endl;} while (next_permutation(arr, arr + 4));return 0;
}

运行结果:

1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1
3 1 2 4
3 1 4 2
3 2 1 4
3 2 4 1
3 4 1 2
3 4 2 1
4 1 2 3
4 1 3 2
4 2 1 3
4 2 3 1
4 3 1 2
4 3 2 1

2.3string

string等数据结构不能直接用名字代表地址,只能够使用自带的迭代器begin()、end()实现全排列。

#define _CRT_SECURE_NO_WARNINGS 1#include <iostream>
#include <algorithm>
using namespace std;int main()
{string s;cin >> s;do{cout << s << endl;}while (next_permutation(s.begin(), s.end()));return 0;
}

运行结果:

abc //inputabc
acb
bac
bca
cab
cba

3.补充

推荐大家使用:cplusplus.com - The C++ Resources Network

可以查询到对应函数对应的头文件、底层代码及使用方式等。

例如:

 剩下的就不多说啦!自己探索叭!

http://www.yayakq.cn/news/905567/

相关文章:

  • 外汇申报在哪个网站上做网络工程师有前途吗
  • 网站seo课程郑州建设最新消息
  • 做网站需要给设计提供毕业视频代做网站
  • 企业产品展示型网站案例怎么用txt做网站
  • 注册网站商标多少钱友情链接系统
  • 上海网站制作工具免费查询网
  • 2019个人建网站专业做ea的网站
  • 绵阳市建设局官方网站自己做视频网站如何接广告
  • 潍坊网站建设 绮畅建设银行官网站查询
  • 辛集建设局官方网站淘客网站seo怎么做
  • 梧州网站建设电话wordpress iis伪静态规则
  • 北京手机网站建设公司好看的网站颜色
  • 织梦网站更换域名游戏游戏大全
  • 你那个没封的网站怎么做啊国外网页设计欣赏
  • 吴江建网站北京征集网站建设
  • 2017网站开发主流工具四川省建设厅职改办网站
  • 企业网站开发毕业报告国际跨境电商平台有哪些
  • 影视视频网站怎么做青岛市做网站优化
  • 宁波建网站找哪家网站建设xs029
  • 陵水网站建设介绍苏州网站开发外包公司
  • 深圳网站建设公司大全网页制作图片大小代码
  • 三种常用的网站设计软件wordpress汉化器
  • 企业门户网站作用蔬菜水果网站建设
  • 做关键词搜索的网站对网站建设的讲话
  • wordpress图片站点如何进行网站网站调试
  • 平台搭建工具做网站排名seo
  • 手机产品网站建设邢台学校网站建设价格
  • 深圳珠宝品牌网站设计百度如何推广产品
  • 做餐饮连锁在哪个网站看临沂手机端建站模板
  • 济南建站公司哪有wordpress替换百度站内搜索