1083. List Grades (25)
Given a list of N student records with name, ID and grade. You is supposed to sort the records with respect to the grade in non-increasing order, and output those student records O F which the grades is in a given interval.
Input Specification:
Each input file contains the one test case. Each case was given in the following format:
NNAME[1] id[1] grade[1]name[2] id[2] grade[2] ... name[n] id[n] Grade[n]grade1 grade2
where Name[i] and id[i] were strings of no more than characters with no space, Grade[i] was an integer in [0, +], Grade 1 and Grade2 are the boundaries of the grade ' s interval. It is guaranteed, the grades is distinct.
Output Specification:
For each test case you should output the student records of which the grades is in the given interval [Grade1, Grade2] an D is in non-increasing order. Each student record occupies a line with the student's name and ID, separated by one space. If There is no student ' s grade in that interval, output "NONE" instead.
Sample Input 1:
4Tom CS000001 59Joe Math990112 89Mike CS991301 100Mary EE990830 9560 100
Sample Output 1:
Mike cs991301mary Ee990830joe Math990112
Sample Input 2:
2Jean AA980920 60Ann CS01 8090 95
Sample Output 2:
NONE
1#include <iostream>2#include <vector>3#include <string>4#include <algorithm>5 6 using namespacestd;7 8 structStudent9 {Ten stringname; One stringID; A intgrade; - }; - the BOOLcmpConststudent& S1,Conststudent&S2) - { - returnS1.grade >S2.grade; - } + -Vector<student> Students (101); + A intMain () at { - intStunum; -CIN >>Stunum; - - for(inti =0; i < Stunum; i++) -CIN >> Students[i].name >> students[i].id >>Students[i].grade; in sort (Students.begin (), Students.end (), CMP); - intgrade1, Grade2; toCIN >> Grade1 >>Grade2; + BOOLFlag =false; - for(inti =0; I < students.size (); i++) the { * if(Students[i].grade >= Grade1&&students[i].grade <=grade2) $ {Panax Notoginsengcout << Students[i].name <<" "<< students[i].id <<Endl; -Flag =true; the } + if(Students[i].grade <grade1) A Break; the } + if(!flag) -cout <<"NONE"; $ $}
PAT 1083. List Grades (25)