2014-07-10 01:57:37
题意&思路:不赘述,直接next_permutation。
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <iostream> 5 using namespace std; 6 7 int main(){ 8 char s[55]; 9 while(scanf("%s",s) == 1){ 10 if(s[0] == '#') break; 11 if(next_permutation(s,s + strlen(s))) cout << s; 12 else cout << "No Successor"; 13 puts(""); 14 } 15 return 0; 16 } 17
本文介绍了一个简单的C++程序,该程序利用STL中的next_permutation函数来找出给定字符串的下一个字典序排列。适用于解决特定类型的字符串排列问题。
1154

被折叠的 条评论
为什么被折叠?



