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 }
更多内容请关注个人微信公众号 物役记 (微信号:materialchains)
作者:雪影蓝枫
本文版权归作者和博客园共有,欢迎转载,未经作者同意须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。


浙公网安备 33010602011771号