1083. List Grades (25)

 


http://www.patest.cn/contests/pat-a-practise/1083

 

 1 #include <stdio.h>

 2 

 3 #include <algorithm>

 4 #include<string.h>

 5 using namespace std;

 6  

 7 struct stu

 8 {

 9    char name[11],id[11];

10    int gra;

11 };

12  

13 bool cmp(stu a,stu b)

14 {

15 return a.gra>b.gra;

16 }

17  

18 int main()

19 {

20 int n,i,grade,gra1,gra2;

21 stu student[100];

22 while(scanf("%d",&n)!=EOF)

23 {

24    for(i=0;i<n;i++)

25    {

26   getchar();

27   scanf("%s%s%d",student[i].name,student[i].id,&student[i].gra);

28    }

29     getchar();

30    scanf("%d%d",&gra1,&gra2);

31    sort(student,student+n,cmp);

32    i=0;

33    while(student[i].gra>gra2)

34    i++;

35    bool b=0;

36    if(i==n) printf("NONE\n");

37    else

38    {

39    for(i;student[i].gra>=gra1;i++)

40    {

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

42    b=1;

43    }

44  

45    if(!b) printf("NONE\n"); 

46    

47    }

48 }

49    return 0;

50 }

 

你可能感兴趣的:(list)