码迷,mamicode.com
首页 > 其他好文 > 详细

PAT 1083

时间:2014-11-08 21:59:55      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   color   ar   os   sp   for   div   

 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

标签:style   blog   io   color   ar   os   sp   for   div   

原文地址:http://www.cnblogs.com/EpisodeXI/p/4084073.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!