以下哪个自定义比较器可以正确实现C++ STL std::sort的多条件排序需求?
现有如下C++代码,意图对存储学生信息的vector按成绩降序排序,成绩相同时按姓名字典序升序排列:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
struct Student {
std::string name;
int score;
};
int main() {
std::vector<Student> stu = {{"Bob", 90}, {"Alice", 90}, {"Charlie", 85}};
std::sort(stu.begin(), stu.end(), 【此处填入比较器】);
return 0;
}
以下哪个选项作为比较器可以实现预期效果?
正在加载题目数据…
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析