如下C++代码运行后的输出结果是?
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
struct Student {
string name;
int score;
};
// 自定义比较函数
bool compare(const Student& a, const Student& b) {
return a.score > b.score;
}
int main() {
vector<Student> students = {{"Alice", 85}, {"Bob", 92}, {"Charlie", 78}};
sort(students.begin(), students.end(), compare);
for(const auto& s : students) {
cout << s.name << " ";
}
return 0;
}
正在加载题目数据…
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析