| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
第100题一次AC,发贴留念#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
class order
{
public:
bool operator() (char x, char y)
{
if (x == y)
return x < y;
if (x == y + 32 || y == x + 32)
return x < y;
if (x >= 'A' && x <= 'Z')
x += 32;
if (y >= 'A' && y <= 'Z')
y += 32;
if (x != y)
return x < y;
}
};
int main()
{
int m;
cin >> m;
string x;
string y;
for (int i = 0; i < m; ++i)
{
cin >> x;
sort(x.begin(), x.end(), order());
cout << x << endl;
y = x;
while(next_permutation(x.begin(), x.end(), order()))
{
if (y != x)
cout << x << endl;
y = x;
}
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator