水题,测了下读题+写题用了8min。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
struct student{
char name[13];
char ID[13];
int grade;
}stu[100020];
bool cmp(student a,student b){
return a.grade>b.grade;
}
int main(){
int n;
scanf("%d",&n);
for (int i=0;i<n;i++){
scanf("%s",&stu[i].name);
scanf("%s",&stu[i].ID);
scanf("%d",&stu[i].grade);
}
int g1,g2;
scanf("%d %d",&g1,&g2);
sort(stu,stu+n,cmp);
bool flag=false;
for (int i=0;i<n;i++){
if (stu[i].grade>=g1 && stu[i].grade<=g2) {
printf("%s %s\n",stu[i].name,stu[i].ID);
flag = true;
}
}
if (flag == false) printf("NONE");
return 0;
}