Day59: [PAT甲级] 1083 List Grades (25分)

Day59: [PAT甲级] 1083 List Grades (25分)

题源:

来自PAT真题库:

https://pintia.cn/problem-sets/994805342720868352/problems/994805383929905152

代码:

dirty code凑合看吧

#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<set>
#include<list>
#include<cstdio>
#include<algorithm>
using namespace std;
int N;
typedef struct stu {
	string name;
	string id;
	int grade;
}stu;
bool cmp(stu A,stu B) {
	return A.grade > B.grade;
}
int main() {
	cin >> N;
	list<stu> v;
	stu X;
	for (int i = 0; i < N; i++) {
		cin >> X.name >> X.id >> X.grade;
		v.push_back(X);
	}
	int left, right;
	cin >> left >> right;
	for (auto iter = v.begin();iter!=v.end();) {
		if (iter->grade<left || iter->grade>right) {
			iter=v.erase(iter);
		}
		else iter++;
	}
	v.sort(cmp);
	if (v.size() == 0) cout << "NONE";
	else
	for (auto iter = v.begin(); iter != v.end();iter++) {
		cout << iter->name << " " << iter->id<<endl;
	}
	system("pause");
}
Day59: [PAT甲级]  1083 List Grades (25分)Day59: [PAT甲级]  1083 List Grades (25分) qq2215459786 发布了58 篇原创文章 · 获赞 13 · 访问量 1309 私信 关注
上一篇:ACM题目 1083: Hello, world!


下一篇:1083 List Grades (25分)