特殊排序+全排列

  POJ-1256

 1 #include <iostream>
 2 #include <cstring>
 3 #include <algorithm>
 4 
 5 using namespace std;
 6 
 7 
 8 char ar[20];
 9 
10 
11 int cmp(char a,char b)
12 {
13     if(tolower(a)!=tolower(b)){
14         return tolower(a)<tolower(b);
15     }
16     else{
17         return a<b;
18     }
19 }
20 
21 int main(int argc, char *argv[]) {
22     int n;
23     string x;
24     cin>>n;
25     while (n--) {
26         cin>>x;
27         const char *cstr = x.c_str();
28         strcpy(ar, cstr);
29         int lenth = strlen(ar);
30         sort(ar, ar+lenth, cmp);
31         do{
32             cout<<ar<<endl;
33         }while (next_permutation(ar, ar+lenth,cmp));
34     }
35     return 0;
36 }

 

posted @ 2019-02-21 15:34  Rohlf  阅读(252)  评论(0编辑  收藏  举报