poj1256(全排列stl)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}

以上是关于poj1256(全排列stl)的主要内容,如果未能解决你的问题,请参考以下文章

ACM题目————STL + 全排列

STL 全排列

STL中的全排列实现

C++ STL 全排列函数详解

全排列(STL)

全排列permutation