#include<bits/stdc++.h>
using namespace std;
bool compare(char a , char b)
{
if(tolower(a)==tolower(b)) return a < b;
return tolower(a) < tolower(b);
}
int main()
{
int t;
cin>>t;
while(t--){
string s;
cin>>s;
sort(s.begin(),s.end(),compare);
cout<<s<<'\n';
while(next_permutation(s.begin(),s.end(),compare))cout<<s<<'\n';
}
return 0;
}
using namespace std;
bool compare(char a , char b)
{
if(tolower(a)==tolower(b)) return a < b;
return tolower(a) < tolower(b);
}
int main()
{
int t;
cin>>t;
while(t--){
string s;
cin>>s;
sort(s.begin(),s.end(),compare);
cout<<s<<'\n';
while(next_permutation(s.begin(),s.end(),compare))cout<<s<<'\n';
}
return 0;
}
No comments:
Post a Comment