#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; }
时间: 2024-11-07 18:31:54