题目说白了就是给你一段字符串 让你给出它的下一个字典序排列
如果没有的话就输出NO SUCCESS!@!@#什么的
好像是这样,我题目也没怎么看懂,
就是用了next_permutation() 函数
这个是用了求下一个字典序的全排列,int char string 都可以拿来用
#include<algorithm>
#include<string>
#include<cstring>
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main(){
string s;
char ch;
while (cin>>s){
if (s == "#")
break;
bool flag=true;
while (next_permutation(s.begin(), s.end())){
flag = false;
cout << s << endl;
break;
}
if (flag)
printf("No Successor\n");
}
return 0;
}
使用next_permutation函数生成字符串的下一个字典序排列
本文介绍了如何利用next_permutation函数为给定的字符串找到下一个字典序排列的方法,提供了代码示例并解释了其实现原理。
1584

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



