#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
bool myCompare(char a, char b)
{
return a>b;
}
struct myCompare2
{
bool operator()(char a, char b)
{
return a>b;
}
};
int main()
{
string str("couragekshaojie");
// sort(str.begin(), str.end(), myCompare);
sort(str.begin(), str.end(), myCompare2());
printf("%s\n", str.c_str());
return 0;
}
对字符串进行排序,学会使用仿函数
最新推荐文章于 2022-05-05 12:46:59 发布