poj1256(全排列stl)

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
bool cmp(char a,char b)
{
if(a>='A'&&a<='Z'&&b>='A'&&b<='Z')
return a<b;
if(a>='a'&&a<='z'&&b<='z'&&b>='a')
return a<b;
if(a>='a'&&a<='z'&&b>='A'&&b<='Z')
return a<(b+32);
if(a>='A'&&a<='Z'&&b>='a'&&b<='z')
return (a+32)<=b;//体现了A<a这一点;
}
int main()
{
int t;
char s[15];
scanf("%d",&t);
while(t--)
{
scanf("%s",s);
int n=strlen(s);
sort(s,s+n,cmp);
do {printf("%s\n",s);
}while(next_permutation(s,s+n,cmp));

}
return 0;
}

上一篇:JS中用execCommand("SaveAs")保存页面兼容性问题解决方案


下一篇:java – Wildfly10 – EJB-Remote Client – 没有响应