竟然还有人用递归,不会不会
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
int cmp(char a,char b)
{
if(tolower(a)!=tolower(b))
return tolower(a)<tolower(b);
else
return a<b;
}
int main()
{
char ch[20];
int m;
cin >> m;
while(m--)
{
scanf("%s",ch);
sort(ch,ch+strlen(ch),cmp);
do
{
printf("%s\n",ch);
}while(next_permutation(ch,ch+strlen(ch),cmp));
}
return 0;
}