解题思路:
注意事项:
参考代码:
#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语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:587 |
三角形 (C语言代码)浏览:903 |
一元一次方程 (C语言代码)浏览:4055 |
找出最长的字符串来 (C语言代码)浏览:1760 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:984 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:556 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:379 |
循环链表与单个结点删除浏览:1102 |
2005年春浙江省计算机等级考试二级C 编程题(3) (C语言描述—高大上之利用二维指针生成二维数组)浏览:1306 |
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:998 |