Sunday, August 17, 2014

uva : 195 - Anagram


#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;

bool myfuntion(char a, char b)
{
char a2 = tolower(a);
char b2 = tolower(b);
if(a2 < b2)
return true;
 if(b2 < a2)
return false;
 return (a < b);
}

int main()
{
    int test;
    scanf("%d",&test);
    while(test--)
    {
        char a[10000];
        scanf("%s",&a);
        sort(a,a+strlen(a),myfuntion);
        puts(a);
        while(next_permutation(a,a+strlen(a),myfuntion))
        {
            puts(a);
        }
    }
    return 0;
}

No comments:

Post a Comment