解题思路:
注意事项:
参考代码:
#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语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:532 |
打水问题 (C语言代码)浏览:1070 |
【偶数求和】 (C语言代码)浏览:556 |
【魔板】 (C++代码)(时间超限,希望会的帮我改正一下)浏览:741 |
母牛的故事 (C语言代码)浏览:1428 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:901 |
1908题解浏览:640 |
简单的a+b (C语言代码)浏览:544 |
大神老白 (C语言代码)浏览:600 |
敲七 (C语言代码)浏览:2700 |