9Google AdSense

ACM Problem Solution : Generating Fast - 10098

View Problem
View Code
-------------------------------------------------------------------------------------------------
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int main()
{
    int t,len;
    char ch;
    char str[10000];
    scanf("%d%c",&t,&ch);
    while(t--)
    {
        gets(str);
        len=strlen(str);
        sort(str,str+len);
        do
        {
            cout<<str<<endl;
        }while(next_permutation(str,str+len));
        cout<<endl;
    }
    return 0;
}

No comments: