第28467题 单选题
以下哪个自定义比较器可以正确实现C++ STL std::sort的多条件排序需求?

现有如下C++代码,意图对存储学生信息的vector按成绩降序排序,成绩相同时按姓名字典序升序排列:```cpp

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; }

A

[](const Student& a, const Student& b) { return a.score > b.score || a.name < b.name; }

B

[](const Student& a, const Student& b) { return a.score > b.score || (a.score == b.score && a.name < b.name); }

C

[](const Student& a, const Student& b) { return a.score < b.score || a.name < b.name; }

D

[](const Student& a, const Student& b) { return a.score > b.score && a.name < b.name; }

程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析