首页 > 学院 > 开发设计 > 正文

1083. List Grades (25)

2019-11-08 01:16:33
字体:
来源:转载
供稿:网友

对输入进行筛选,选取在范围内的学生数据,然后对筛选的数据进行排序输出就好了

#include<iostream>#include<string>#include<vector>#include<algorithm>using namespace std;struct node{ string name; string id; int grade; bool Operator<(const node that) const { return grade > that.grade; }};vector<node> all;//保存输出vector<node> re;//存储结果输出int main(){ int N; cin >> N; all.resize(N); for (int t = 0;t < N;t++) cin >> all[t].name >> all[t].id >> all[t].grade; int m, M; cin >> m >> M; for (auto x : all) if (x.grade >= m&&x.grade <= M) re.push_back(x); sort(re.begin(), re.end()); if (re.empty()) cout << "NONE" << endl; else for (auto x : re) cout << x.name << " " << x.id << endl;}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表