Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <fstream>
  2. #include <cstring>
  3. using namespace std;
  4. ifstream cin("anagrame1.in");
  5. ofstream cout("anagrame1.out");
  6. char s[256];
  7. int A[1001],P[1001],C[101][101],cnt=1,cnt1;
  8. void afis()
  9. {
  10. for(int i = 0;s[i];i++)
  11. cout << s[A[i]];
  12. cout << endl;
  13. }
  14. void back(int k)
  15. {
  16. for(int i = 0;s[i];i++)
  17. if(!P[i])
  18. {
  19. A[k] = i;
  20. P[i]=1;
  21. if(k==strlen(s)-1)
  22. afis();
  23. else back(k+1);
  24. P[i]=0;
  25. }
  26. }
  27.  
  28. int main()
  29. {
  30. cin >> s;
  31. for(int i = 0; i < strlen(s)-1;i++)
  32. for(int j = i + 1; j < strlen(s);j++)
  33. if(s[i] > s[j])
  34. {
  35. char aux = s[i];
  36. s[i] = s[j];
  37. s[j] = aux;
  38. }
  39. back(0);
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement