Source: Internet
Author: User

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`

Source: >
```

`#pragma warning(disable:4996)`

`#include <stdio.h>`

`#include <string>`

`#include <iostream>`

`#include <algorithm>`

`#include <vector>`

`using namespace std;`

`struct Stu`

`{`

`char name[11];`

`char id[11];`

`int grade;`

`};`

`vector<Stu> s,s1;`

`bool cmp(Stu a,Stu b) {`

`return a.grade > b.grade;`

`}`

`int main(void) {`

`int n;`

`cin >> n;`

`for (int i = 0; i < n; i++) {`

`Stu temp;`

`scanf("%s %s %d", temp.name, temp.id, &temp.grade);`

`s.push_back(temp);`

`}`

`int low, high;`

`cin >> low >> high;`

`  Span class= "KWD" >for    ( int   i  =    0    I  <   n    I  ++)    { `

`  Span class= "KWD" >if    ( s  [ i  .  grade  >=   low  &&  s  [ i  .  grade  <=   high     { `

`s1.push_back(s[i]);`

`}`

`}`

`if (s1.size() == 0) {`

`cout << "NONE";`

`return 0;`

`}`

`sort(s1.begin(), s1.end(), cmp);`

`  Span class= "KWD" >for    ( int   i  =    0    I  <   S1   size   ();   I  ++)    { `

`printf("%s %s\n", s1[i].name, s1[i].id);`

`}`

`return 0;`

`}`

```

From for notes (Wiz)

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.