#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<cctype>//里面有isdigit():数字字符返回true
using namespace std;
struct node{
char name[15];
char id[15];
int grade;
}stu[50];
bool cmp(node x,node y){
return x.grade>y.grade;
}
int main(){
int n,grade1,grade2;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%s %s %d",&stu[i].name,&stu[i].id,&stu[i].grade);
}
sort(stu,stu+n,cmp);
scanf("%d %d",&grade1,&grade2);
int pos=0;
/*
while(pos<n&&(stu[pos].grade>=grade1&&stu[pos].grade<=grade2)){
printf("%s %s\n",stu[pos].name,stu[pos].id);
pos++;
}
*/
for(int i=0;i<n;i++){
if(stu[i].grade>=grade1&&stu[i].grade<=grade2){
printf("%s %s\n",stu[i].name,stu[i].id);
pos=1;
}
}
if(pos==0){
printf("NONE");
}
return 0;
}
想问循环那用while为什么不行?