首页 > 代码库 > PAT 1083
PAT 1083
1 #include <vector> 2 #include <algorithm> 3 #include <string> 4 #include <iostream> 5 6 using namespace std; 7 8 struct Student{ 9 int grade;10 string name;11 string id;12 };13 14 bool compare(const Student &s1, const Student &s2){15 return s1.grade > s2.grade;16 }17 18 int main(){19 int N;20 cin >> N;21 22 vector<Student> students;23 24 for (int i = 0; i < N; i++){25 Student s;26 cin >> s.name >> s.id >> s.grade;27 28 students.push_back(s);29 }30 31 int low, high;32 cin >> low >> high;33 34 sort(students.begin(), students.end(), compare);35 bool none = true;36 for (int i = 0; i < students.size(); i++){37 if (students[i].grade < low)38 break;39 if (students[i].grade > high)40 continue;41 42 none = false;43 cout << students[i].name << " " << students[i].id << endl;44 }45 46 if (none)47 cout << "NONE" << endl;48 49 return 0;50 }
PAT 1083
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。