Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // next_permutation
- #include <bits/stdc++.h>
- #define IO ios::sync_with_stdio(0);cin.tie(0)
- #define endl '\n'
- using namespace std;
- int t;
- string s;
- bool cmp(char, char);
- int main()
- {
- IO;
- cin >> t;
- cin.ignore();
- while (t--) {
- getline(cin, s);
- sort(s.begin(), s.end(), cmp);
- do {
- cout << s << endl;
- } while (next_permutation(s.begin(), s.end(), cmp));
- }
- return 0;
- }
- bool cmp (char a, char b)
- {
- char tmpa = tolower(a), tmpb = tolower(b);
- return tmpa < tmpb || (tmpa == tmpb && a < b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement