#include <iostream>
#include<algorithm>
using namespace std;
int main() {
string str;
cin>>str;
str.erase(str.end() - 1);
sort(str.begin(),str.end());
do{
cout<<str<<" ";
}while(next_permutation(str.begin(),str.end()));//next_permutation()会取得[first,last)所标示之序列的下一个排列组合,如果没有下一个排列组合,便返回false;否则返回true。
return 0;
}
中国矿业大学——算法实验1.2——排列问题
最新推荐文章于 2025-12-15 09:15:21 发布
该C++程序接受用户输入的字符串,删除最后一个字符,然后对剩余字符进行排序。使用next_permutation函数生成所有可能的排列组合并打印。
5147

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



