解题思路:
注意事项:
参考代码:
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <string> #include <algorithm> #include <stdio.h> using namespace std; class Student { public: Student(); Student(string name, string gender, int age, int score) :name(name), gender(gender), age(age), score(score) { } ~Student(); string name; string gender; int age; int score; }; Student::Student() { } Student::~Student() { } vector<Student> stuArr; bool cmp(Student a, Student b) { return a.score < b.score; } int main(int argc, char** argv) { int n = 0; cin >> n; for (int i = 0; i < n; i++) { string name, gender; int age, score; cin >> name >> gender >> age >> score; stuArr.push_back(Student(name, gender, age, score)); } stable_sort(stuArr.begin(), stuArr.end(), cmp); for (vector<Student>::iterator it = stuArr.begin(); it < stuArr.end(); it++) cout << it->name << " " << it->gender << " " << it->age << " " << it->score << endl; return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:643 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:387 |
printf基础练习2 (C语言代码)浏览:826 |
wu-淘淘的名单 (C++代码)浏览:1532 |
WU-整数平均值 (C++代码)浏览:1307 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:544 |
简单的a+b (C语言代码)浏览:626 |
模拟计算器 (C++代码)浏览:885 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:567 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:1207 |