// With String
// Accepted
#include <bits/stdc++.h>
using namespace std;
bool cmpr (char a, char b)
{
if (tolower(a) == tolower(b))
{
return a<b;
}
return (tolower(a) < tolower(b));
}
int main()
{
int t;
char ch[1010];
string s;
cin >> t; getchar();
while (t--)
{
//getline(cin,s);
//cin.ignore();
//scanf("%s",&ch);
cin >> s;
//int len = strlen(ch);
sort (s.begin(),s.end(),cmpr);
do
{
cout << s << endl;
//printf("%c\n",ch);
}while (next_permutation(s.begin(),s.end(),cmpr));
}
return 0;
}
// with Charecter
// Accepted
#include <bits/stdc++.h>
using namespace std;
bool cmpr (char a, char b)
{
if (tolower(a) == tolower(b))
{
return a<b;
}
return tolower(a) < tolower(b);
}
int main()
{
int t;
char ch[1010];
cin >> t;
getchar();
while (t--)
{
scanf("%s",&ch);
sort (ch,ch+strlen(ch),cmpr);
do
{
cout << ch << endl;
}while (next_permutation(ch,ch+strlen(ch),cmpr));
}
return 0;
}
Comments
Post a Comment