//考察点: next_permutation的用法 考察了设计cmp函数的能力
//思路 只要写出满足条件的cmp函数就可以了 利用奇偶性把大小写字母错开. 于是想到了cmp函数的书写方式
//提交情况 1WA 1AC 第一次错了是因为交错题目了!!
//收获: 学到了处理这种比较函数的方法 如果还有一种A就可以乘以三 然后再利用初始相位进行划分.
//经验: 写next_permutation的时候因为需要打印出最早的一个情况 所以用的 do while 形式
//ACcode:
//思路 只要写出满足条件的cmp函数就可以了 利用奇偶性把大小写字母错开. 于是想到了cmp函数的书写方式
//提交情况 1WA 1AC 第一次错了是因为交错题目了!!
//收获: 学到了处理这种比较函数的方法 如果还有一种A就可以乘以三 然后再利用初始相位进行划分.
//经验: 写next_permutation的时候因为需要打印出最早的一个情况 所以用的 do while 形式
//ACcode:
#include
<
stdio.h
>
#include < algorithm >
#include < string .h >
using namespace std;
int f( char x)
{
if ( ' a ' <= x && x <= ' z ' ) return (x - ' a ' + 1 ) * 2 ;
else return (x - ' A ' ) * 2 + 1 ;
}
bool cmp( char x, char y)
{
return f(x) < f(y);
}
int main()
{
// freopen("pku_1256_in.txt","r",stdin);
char a[ 15 ];
int t;
int n;
scanf( " %d " , & t);
while (t -- )
{
scanf( " %s " ,a);
n = strlen(a);
sort(a,a + n,cmp);
do
{
printf( " %s\n " ,a);
} while (next_permutation(a,a + n,cmp));
}
return 0 ;
}
#include < algorithm >
#include < string .h >
using namespace std;
int f( char x)
{
if ( ' a ' <= x && x <= ' z ' ) return (x - ' a ' + 1 ) * 2 ;
else return (x - ' A ' ) * 2 + 1 ;
}
bool cmp( char x, char y)
{
return f(x) < f(y);
}
int main()
{
// freopen("pku_1256_in.txt","r",stdin);
char a[ 15 ];
int t;
int n;
scanf( " %d " , & t);
while (t -- )
{
scanf( " %s " ,a);
n = strlen(a);
sort(a,a + n,cmp);
do
{
printf( " %s\n " ,a);
} while (next_permutation(a,a + n,cmp));
}
return 0 ;
}