灰常简单,5分钟AC,求下一个排列,直接用库函数next_permutation搞定
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
char str[11];
cin>>str;
int len=strlen(str);
sort(str,str+len);
do
{
for (int i=0;i<len;i++)
cout<<str[i];
cout<<endl;
}while(next_permutation(str,str+len));
cout<<endl;
}
return 0;
}