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 |
写了一个更短小精悍的代码#include<iostream> #include<string> #include<cstring> #include<algorithm> using namespace std; bool cmp(char c1,char c2){ if(tolower(c1) == tolower(c2)) return c1 < c2; else return tolower(c1) < tolower(c2); } int main(){ int n; cin >> n; int i; string str; for(i = 0; i < n; i++){ cin >> str; sort(str.begin(),str.end(),cmp); do{ cout << str << endl; }while(next_permutation(str.begin(),str.end(),cmp)); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator