1083 List Grades (25 分)
#include <stdio.h>
#include <algorithm>
struct student{
char name[88];
char id[88];
int grade;
int flag=0;
};
bool cmp (student a,student b);
using namespace std;
int main ()
{
int a,b,i,n,q=0;
scanf ("%d",&n);
struct student stu[n];
for (i=0;i<n;i++)
scanf ("%s %s %d",stu[i].name,stu[i].id,&stu[i].grade);
scanf ("%d %d",&a,&b);
for (i=0;i<n;i++)
{
if (stu[i].grade>=a&&stu[i].grade<=b)
{
stu[i].flag=1;
q++;
}
}
sort (stu,stu+n,cmp);
if (q==0)
printf ("NONE");
else
{
for (i=0;i<n;i++)
{
if (stu[i].flag==1)
printf ("%s %s\n",stu[i].name,stu[i].id);
}
}
return 0;
}
bool cmp (student a,student b)
{
return a.grade>b.grade;
}
|