#include #include #include using namespace std;

struct Student { string name; int score; };

bool compare(Student a, Student b) { return a.score > b.score; }

int main() { vector students; for (int i = 0; i < 10; i++) { string name; int score; cin >> name >> score; Student student; student.name = name; student.score = score; students.push_back(student); } sort(students.begin(), students.end(), compare); for (int i = 0; i < students.size(); i++) { cout << students[i].name << " " << students[i].score << endl; } return 0;

cppCPU占用时长 1秒内存使用限制 128MB题目描述A班刚考过一门考试输入10个学生的姓名与成绩将学生信息按成绩由大到小排序后输出每个学生一行。输入格式输出格式输入输出样例样例 1输入样例 复制zhang 80wang 74li 95zhao 96chen 90xiao 100qian 80sun 66liu 75dong 80输出样例 复制xiao 100zhao 96li 95chen

原文地址: http://www.cveoy.top/t/topic/iC6b 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录