原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113
字符串简单题:
stl水过
如下:

1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cstdio> 6 #include<string> 7 #include<map> 8 #include<set> 9 using std::set; 10 using std::map; 11 using std::sort; 12 using std::string; 13 using std::next_permutation; 14 set<string> rec; 15 int _main(){ 16 #ifdef LOCAL 17 freopen("in.txt", "r", stdin); 18 freopen("out.txt", "w+", stdout); 19 #endif 20 int c = 0; 21 char buf[10], tmp[10]; 22 while (~scanf("%s", buf) && c != 2){ 23 if (!c && strcmp(buf, "XXXXXX") != 0) rec.insert(buf); 24 else if (0 == strcmp(buf, "XXXXXX")) c++; 25 else { 26 int flag = 0, n = strlen(buf); 27 strcpy(tmp, buf); 28 sort(tmp, tmp + n); 29 do{ 30 if (rec.count(tmp) != 0) flag = 1, printf("%s ", tmp); 31 } while (next_permutation(tmp, tmp + n)); 32 if (!flag) printf("NOT A VALID WORD ", tmp); 33 printf("****** "); 34 } 35 } 36 return 0; 37 }