标签: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 }
标签:style blog io color ar os sp for div
原文地址:http://www.cnblogs.com/EpisodeXI/p/4084073.html