首页 > 其他 > 详细

poj1256(全排列stl)

时间:2016-10-16 16:54:24      阅读:313      评论:0      收藏:0      [点我收藏+]

#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;
}

poj1256(全排列stl)

原文:http://www.cnblogs.com/liuzhixin-123/p/5966784.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!