Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <cstring>
- using namespace std;
- ifstream cin("anagrame1.in");
- ofstream cout("anagrame1.out");
- char s[256];
- int A[1001],P[1001],C[101][101],cnt=1,cnt1;
- void afis()
- {
- for(int i = 0;s[i];i++)
- cout << s[A[i]];
- cout << endl;
- }
- void back(int k)
- {
- for(int i = 0;s[i];i++)
- if(!P[i])
- {
- A[k] = i;
- P[i]=1;
- if(k==strlen(s)-1)
- afis();
- else back(k+1);
- P[i]=0;
- }
- }
- int main()
- {
- cin >> s;
- for(int i = 0; i < strlen(s)-1;i++)
- for(int j = i + 1; j < strlen(s);j++)
- if(s[i] > s[j])
- {
- char aux = s[i];
- s[i] = s[j];
- s[j] = aux;
- }
- back(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement