Create 1256.cpp

This commit is contained in:
Kirigaya Kazuto 2016-08-19 11:18:41 +08:00 committed by GitHub
parent ec320f8da6
commit 6adc773c83

40
POJ/1256.cpp Normal file
View File

@ -0,0 +1,40 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
char buff[1024];
//vector<string> vec;
bool cmp(const char& a,const char& b)
{
char c=a>='a'?a-'a':a-'A';
char d=b>='a'?b-'a':b-'A';
if(c!=d) return c<d;
else return a<b;
}
int main()
{
int t;
scanf("%d%*c",&t);
for(int i=0;i<t;i++)
{
gets(buff);
string str(buff);
sort(str.begin(),str.end(),cmp);
////What? You mean this is needn't?
//if(find(vec.begin(),vec.end(),str)!=vec.end()) continue;
//vec.push_back(str);
printf("%s\n",str.c_str());
while(next_permutation(str.begin(),str.end(),cmp))
{
printf("%s\n",str.c_str());
}
}
return 0;
}