STL_全排列

  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. using namespace std;
  5. int main()
  6. {string a;
  7. while(cin>>a){
  8. sort(a.begin(),a.end());
  9. do
  10. {
  11.  cout<<a.begin()<<endl;
  12. }while(std::next_permutation(a.begin(),a.end()));
  13. }
  14. return 0;
  15. }

例子:

1 2 3

1 3 2

2 1 3

2 3 1

3 1 2

3 2 1(希望我没写错-_________________-)

你可能感兴趣的:(permutation)