Fork me on GitHub

Uva 146 - ID Codes

 

 ID Codes 

题目链接:

 

 

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=107&page=show_problem&problem=82

初学者用STL明显的就会让大脑迟钝,一个next_permutation()搞定了

详情请看刘汝佳的竞赛入门P120

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 
 6 int main()
 7 {
 8 /*    freopen("input.txt", "r", stdin); */
 9     int n;
10     char p[54];
11     while(scanf("%s", p) != EOF && strcmp(p, "#") != 0)
12     {
13         n = strlen(p);
14         if(next_permutation(p, p+n))
15         {
16             printf("%s\n", p);
17         }
18         else printf("No Successor\n");
19     }
20     return 0;
21 }

 

 

 

 

 

posted @ 2013-04-16 06:40  Gifur  阅读(211)  评论(0)    收藏  举报
TOP