Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Created February 13, 2014 12:57
Show Gist options
  • Select an option

  • Save KT-Yeh/8974623 to your computer and use it in GitHub Desktop.

Select an option

Save KT-Yeh/8974623 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n;
string str;
cin >> n;
while (n--){
cin >> str;
sort(str.begin(), str.end());
do{
for (char &c : str) // c++11 new standard:用來走遍所有元素
cout << c;
cout << endl;
} while (next_permutation(str.begin(), str.end()));
cout << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment