Thursday, March 17, 2011

10098 - Generating Fast


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    char str[15];
    register int n,len;
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    gets(str);
    while(n--)
    {
        gets(str);
        len=strlen(str);
        sort(str,str+len);
        do{
            printf("%s\n",str);
        }while(next_permutation(str,str+len));
        printf("\n");
    }
    return 0;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.