Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- #include<sstream>
- #include<cstdlib>
- #include<cctype>
- #include<cmath>
- #include<algorithm>
- #include<set>
- #include<queue>
- #include<stack>
- #include<list>
- #include<iostream>
- #include<fstream>
- #include<numeric>
- #include<string>
- #include<vector>
- #include<cstring>
- #include<map>
- #include<iterator>
- using namespace std;
- char permutation[12];
- void acseding(char N[])
- {
- char temp;
- for(int I=0; I<strlen(N); I++)
- {
- for(int J=I+1; J<strlen(N); J++)
- {
- if(N[I] > N[J])
- {
- temp = N[I];
- N[I] = N[J];
- N[J] = temp;
- }
- }
- }
- }
- void P(int k,char w[],int ln,int check[])
- {
- if(k == ln)
- {
- permutation[k] = '\0';
- printf("%s\n",permutation);
- return;
- }
- else
- {
- for(int x=0; x<strlen(w); x++)
- {
- if(check[x] == 0)
- {
- check[x] = 1;
- permutation[k] = w[x];
- k++;
- P(k,w,ln,check);
- check[x] = 0;
- k--;
- }
- }
- }
- }
- int main()
- {
- char test[10];
- gets(test);
- int t = atoi(test);
- while(t--)
- {
- char word[12];
- int che[12]={0};
- permutation[0] = '\0';
- gets(word);
- acseding(word);
- int lnth = strlen(word);
- P(0,word,lnth,che);
- cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement