#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  vector<int> vec1;
  for (int k=0;k<5;k++)
  {
    vec1.push_back(rand());
  }

  vector<int>::iterator vec_iter1;
  for (vec_iter1 = vec1.begin();vec_iter1 != vec1.end();++vec_iter1)
  {
    cout << *vec_iter1 << " ";
  }
  cout << endl;
  cout << "----------------------------------" << endl;

  
  while (next_permutation(vec1.begin(),vec1.end()))
  {
    for (vector<int>::iterator vec_iter2 = vec1.begin(); vec_iter2 != vec1.end(); ++vec_iter2)
    {
      cout << *vec_iter2 << " ";
    }
    cout << endl;
    cout << "----------------------------------" << endl;
  }

  system("pause");
  return 0;
}

========================================

41 18467 6334 26500 19169
----------------------------------
41 18467 19169 6334 26500
----------------------------------
41 18467 19169 26500 6334
----------------------------------
41 18467 26500 6334 19169
----------------------------------
41 18467 26500 19169 6334
----------------------------------
41 19169 6334 18467 26500
----------------------------------
41 19169 6334 26500 18467
----------------------------------
41 19169 18467 6334 26500
----------------------------------
41 19169 18467 26500 6334
----------------------------------
41 19169 26500 6334 18467
----------------------------------
41 19169 26500 18467 6334
----------------------------------
41 26500 6334 18467 19169
----------------------------------
41 26500 6334 19169 18467
----------------------------------
41 26500 18467 6334 19169
----------------------------------
41 26500 18467 19169 6334
----------------------------------
41 26500 19169 6334 18467
----------------------------------
41 26500 19169 18467 6334
----------------------------------
6334 41 18467 19169 26500
----------------------------------
6334 41 18467 26500 19169
----------------------------------
6334 41 19169 18467 26500
----------------------------------
6334 41 19169 26500 18467
----------------------------------
6334 41 26500 18467 19169
----------------------------------
6334 41 26500 19169 18467
----------------------------------
6334 18467 41 19169 26500
----------------------------------
6334 18467 41 26500 19169
----------------------------------
6334 18467 19169 41 26500
----------------------------------
6334 18467 19169 26500 41
----------------------------------
6334 18467 26500 41 19169
----------------------------------
6334 18467 26500 19169 41
----------------------------------
6334 19169 41 18467 26500
----------------------------------
6334 19169 41 26500 18467
----------------------------------
6334 19169 18467 41 26500
----------------------------------
6334 19169 18467 26500 41
----------------------------------
6334 19169 26500 41 18467
----------------------------------
6334 19169 26500 18467 41
----------------------------------
6334 26500 41 18467 19169
----------------------------------
6334 26500 41 19169 18467
----------------------------------
6334 26500 18467 41 19169
----------------------------------
6334 26500 18467 19169 41
----------------------------------
6334 26500 19169 41 18467
----------------------------------
6334 26500 19169 18467 41
----------------------------------
18467 41 6334 19169 26500
----------------------------------
18467 41 6334 26500 19169
----------------------------------
18467 41 19169 6334 26500
----------------------------------
18467 41 19169 26500 6334
----------------------------------
18467 41 26500 6334 19169
----------------------------------
18467 41 26500 19169 6334
----------------------------------
18467 6334 41 19169 26500
----------------------------------
18467 6334 41 26500 19169
----------------------------------
18467 6334 19169 41 26500
----------------------------------
18467 6334 19169 26500 41
----------------------------------
18467 6334 26500 41 19169
----------------------------------
18467 6334 26500 19169 41
----------------------------------
18467 19169 41 6334 26500
----------------------------------
18467 19169 41 26500 6334
----------------------------------
18467 19169 6334 41 26500
----------------------------------
18467 19169 6334 26500 41
----------------------------------
18467 19169 26500 41 6334
----------------------------------
18467 19169 26500 6334 41
----------------------------------
18467 26500 41 6334 19169
----------------------------------
18467 26500 41 19169 6334
----------------------------------
18467 26500 6334 41 19169
----------------------------------
18467 26500 6334 19169 41
----------------------------------
18467 26500 19169 41 6334
----------------------------------
18467 26500 19169 6334 41
----------------------------------
19169 41 6334 18467 26500
----------------------------------
19169 41 6334 26500 18467
----------------------------------
19169 41 18467 6334 26500
----------------------------------
19169 41 18467 26500 6334
----------------------------------
19169 41 26500 6334 18467
----------------------------------
19169 41 26500 18467 6334
----------------------------------
19169 6334 41 18467 26500
----------------------------------
19169 6334 41 26500 18467
----------------------------------
19169 6334 18467 41 26500
----------------------------------
19169 6334 18467 26500 41
----------------------------------
19169 6334 26500 41 18467
----------------------------------
19169 6334 26500 18467 41
----------------------------------
19169 18467 41 6334 26500
----------------------------------
19169 18467 41 26500 6334
----------------------------------
19169 18467 6334 41 26500
----------------------------------
19169 18467 6334 26500 41
----------------------------------
19169 18467 26500 41 6334
----------------------------------
19169 18467 26500 6334 41
----------------------------------
19169 26500 41 6334 18467
----------------------------------
19169 26500 41 18467 6334
----------------------------------
19169 26500 6334 41 18467
----------------------------------
19169 26500 6334 18467 41
----------------------------------
19169 26500 18467 41 6334
----------------------------------
19169 26500 18467 6334 41
----------------------------------
26500 41 6334 18467 19169
----------------------------------
26500 41 6334 19169 18467
----------------------------------
26500 41 18467 6334 19169
----------------------------------
26500 41 18467 19169 6334
----------------------------------
26500 41 19169 6334 18467
----------------------------------
26500 41 19169 18467 6334
----------------------------------
26500 6334 41 18467 19169
----------------------------------
26500 6334 41 19169 18467
----------------------------------
26500 6334 18467 41 19169
----------------------------------
26500 6334 18467 19169 41
----------------------------------
26500 6334 19169 41 18467
----------------------------------
26500 6334 19169 18467 41
----------------------------------
26500 18467 41 6334 19169
----------------------------------
26500 18467 41 19169 6334
----------------------------------
26500 18467 6334 41 19169
----------------------------------
26500 18467 6334 19169 41
----------------------------------
26500 18467 19169 41 6334
----------------------------------
26500 18467 19169 6334 41
----------------------------------
26500 19169 41 6334 18467
----------------------------------
26500 19169 41 18467 6334
----------------------------------
26500 19169 6334 41 18467
----------------------------------
26500 19169 6334 18467 41
----------------------------------
26500 19169 18467 41 6334
----------------------------------
26500 19169 18467 6334 41
----------------------------------
请按任意键继续. . .

C++ STL 排列 next_permutation prev_permutation的更多相关文章

  1. C++ STL:next_permutation和prev_permutation

    两个函数都在#include <algorithm>里 顾名思义,next_permutation用来求下一个排列,prev_permutation用来求上一个排列. 当前的排列不满足函数 ...

  2. P4163 [SCOI2007]排列——next_permutation

    P4163 [SCOI2007]排列 注意要排序: next_permutation prev_permutation #include<cstdio> #include<cstri ...

  3. 使用STL的next_permutation函数

    文章作者:姜南(Slyar) 文章来源:Slyar Home (www.slyar.com) 转载请注明,谢谢合作. 下午研究了一下全排列算法,然后发现C++的STL有一个函数可以方便地生成全排列,这 ...

  4. suseoj 1208: 排列问题 (STL, next_permutation(A.begin(), A.end()))

    1208: 排列问题 时间限制: 1 Sec  内存限制: 128 MB提交: 2  解决: 2[提交][状态][讨论版][命题人:liyuansong] 题目描述 全排列的生成就是对于给定的字符集或 ...

  5. C++ STL next_permutation() prev_permutation(a,a+n)用法。

    int a[3] = {1,2,3}; a可能形成的集合为{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}. {2,1,3}的prev是{1,3,2}, ...

  6. 【STL】next_permutation的原理和使用

    1.碰到next_permutation(permutation:序列的意思) 今天在TC上碰到一道简单题(SRM531 - Division Two - Level One),是求给定数组不按升序排 ...

  7. stl算法:next_permutation剖析

    在标准库算法中,next_permutation应用在数列操作上比较广泛.这个函数可以计算一组数据的全排列.但是怎么用,原理如何,我做了简单的剖析. 首先查看stl中相关信息.函数原型: templa ...

  8. 8-全排列next_permutation

    C++中全排列函数next_permutation 用法 转载 2017年03月29日 14:38:25 1560 全排列参考了两位的博客 感谢! http://blog.sina.com.cn/s/ ...

  9. 九度OJ 1120 全排列 -- 实现C++STL中next_permutation()

    题目地址:http://ac.jobdu.com/problem.php?pid=1120 题目描述: 给定一个由不同的小写字母组成的字符串,输出这个字符串的所有全排列. 我们假设对于小写字母有'a' ...

随机推荐

  1. [Selenium3+python3.6]自动化测试3-八种元素元素定位(Firebug和firepath)

    参考http://www.cnblogs.com/yoyoketang/p/6123890.html   #coding=utf-8 from selenium import webdriverdri ...

  2. Vs2017 FrameWork EF Mysql Mvc 三层整合1

    1  运行环境   vs2017   Net FromWork 4.6.2  手动版 没有 ado.net 实体数据模型 2 NuGet  MySql.Data.Entity 6.10.9, MySq ...

  3. airtest使用

    airtest Airtest是网易开发的手机UI界面自动化测试工具 通过截图功能操作手机虽然方便,但是截图涉及到分辨率的问题,代码不能在不同的手机上通用. 可以用来开发手机App爬虫 使用先抓大再抓 ...

  4. 创建守护进程步骤与setsid()

    原创:http://www.cnblogs.com/mickole/p/3188321.html 一,守护进程概述 Linux Daemon(守护进程)是运行在后台的一种特殊进程.它独立于控制终端并且 ...

  5. jQuery属性遍历、HTML操作

    jQuery 拥有可操作 HTML 元素和属性的强大方法. jQuery 遍历函数 jQuery 遍历函数包括了用于筛选.查找和串联元素的方法.    .add() 将元素添加到匹配元素的集合中. . ...

  6. Ubuntu系统---NVIDIA 驱动安装

    Ubuntu系统---NVIDIA 驱动安装 第一次安装“NVIDIA 驱动”,小小的激动,因为终于可以玩GPU了.预想一块GPU,盼望太久,差点放弃,感谢J姐让我捡个漏.但是,第一次新的试错过程,网 ...

  7. springboot中访问html页面

    springboot中如果想访问html页面,不每访问一个页面就写一个Controller,可以统一写一个公共的controller方法 代码: (1)引入hutool工具依赖 <!-- hut ...

  8. APP微信登录 服务器处理代码

    采用框架THINKPHP5 需要客户端传的参数有  udid openid nickname avatar_path /* * @param 第三方微信登录 * @param openid udid ...

  9. 【数位DP-板子题目】HDU-3555-Bomb- [只要49]

    Bomb Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...

  10. Selenium(五)鼠标和键盘事件

    1.模拟鼠标找到大分类下的子分类.以网易严选为例. 如果直接找到  坚果炒货 这个元素,然后点击它来实现跳转,是会报错的. 模拟鼠标停留--点击行为:  页面已成功跳转 2.键盘事件 模拟搜索操作: ...