#include<cstdio>
struct person{
char name[15];
char id[15];
int score;
}M,F,temp;
void init(){
M.score=101;
F.score=-1;
}
int main(){
init();
int n;
char gender;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%s %c %s %d",temp.name,&gender,temp.id,&temp.score);
if(gender=='M'&&temp.score<M.score){
M=temp;
}else if(gender=='F'&&temp.score>F.score){
F=temp;
}
}
if(F.score==-1)printf("Absent\n");
else printf("%s %s\n",F.name,F.id);
if(M.score==101)printf("Absent\n");
else printf("%s %s\n",M.name,M.id);
if(F.score==-1||M.score==101)printf("NA\n");
else printf("%d\n",F.score-M.score);
return 0;
}
Boys VS Girls 题解
最新推荐文章于 2022-11-21 21:29:08 发布
这段C++代码定义了一个结构体`person`来存储姓名、ID和分数,初始化男性和女性的最高分,然后读取n个人的数据,更新男性和女性的最高分记录。最后,如果找不到女性或男性的最高分,则输出Absent,否则输出姓名、ID和分数差值。
405

被折叠的 条评论
为什么被折叠?



