Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <vector>
  5. using namespace std;
  6. int main ()
  7. {
  8. int t;
  9. cin>>t;
  10. for(int i=0; i<t; i++)
  11. {
  12. vector <int> v;
  13. string s;
  14. cin>>s;
  15. int k=s.size();
  16. sort(s.begin(), s.begin()+k);
  17. for(int j=0; j<s.size(); j++)
  18. {
  19. v.push_back(j);
  20. }
  21. k=v.size();
  22.  
  23. do
  24. {
  25. for(int z=0; z<k; z++)
  26. {
  27. cout<<s[v[z]];
  28. }
  29. cout<<endl;
  30. }while(next_permutation(v.begin(),v.begin()+k));
  31. cout<<endl;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement