当前位置:首页 > 开发 > Web前端 > Ext > 正文

next_permutation

发表于: 2015-11-13   作者:互联网   来源:转载   浏览:
ext
摘要: // next_permutation #include <iostream> #include <algorithm> using namespace std; int main () { int myints[] = {1,2,3}; cout << "The 3! possible permutations with
// next_permutation

#include <iostream>

#include <algorithm>

using namespace std;



int main () {

  int myints[] = {1,2,3};



  cout << "The 3! possible permutations with 3 elements:\n";



  sort (myints,myints+3);



  do {

    cout << myints[0] << " " << myints[1] << " " << myints[2] << endl;

  } while ( next_permutation (myints,myints+3) );



  return 0;

}

Output:

The 3! possible permutations with 3 elements:

1 2 3

1 3 2

2 1 3

2 3 1

3 1 2

3 2 1

 


 

next_permutation

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号