| ||||||||||
| 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 | |||||||||
Re:写了一个更短小精悍的代码In Reply To:写了一个更短小精悍的代码 Posted by:fuliang at 2009-05-05 00:25:44 哥也帖一个
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
bool cmp(const char a, const char b)
{
if( (a|32)==(b|32) ) return a<b;
else return (a|32)<( b|32);
}
int main()
{
int t;
cin>>t;
string str;
while(t--)
{
cin>>str;
sort(&str[0],&str[str.size()],cmp);
cout<<str<<endl;
while(next_permutation(&str[0], &str[str.size()],cmp))
cout<<str<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator