题目大意:输入字符串,按字典序输出所有排列。注意(A>a>B>b..)。使用头文件algorithm里面的sort(iterator start, iterator end ,cmp),next_permutation(iterator start, iterator end ,cmp)方法,该方法按cmp方法的比较输出全排列。
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
//将字符转为浮点数便于比较,因为同一个字母大小写在一起,所以小写字母-31.5
bool cmp(char a, char b){
double a1 = a;
double b1 = b;
if (a1 >= 97)
a1 = a1 - 31.5

博客内容介绍了如何使用C++中的`algorithm`库,特别是`sort`和`next_permutation`函数,来解决字典序输出字符串全排列的问题。强调了(A>a>B>b..)的排序规则。
最低0.47元/天 解锁文章

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



