1036. Boys vs Girls (25)

时间:2021-03-25 14:51:00

#include <stdio.h>
#include <string.h>
int main()
{
int n,i;
while(scanf("%d",&n)!=EOF)
{
char ManID[11]="",FelID[11]="",ManName[11],FelName[11];
char TemID[11],TemName[11],Gender;
int TemGrade,MaxGrade=-1,MinGrade=101;
for(i=0;i<n;i++)
{
getchar();
scanf("%s %c %s %d",TemName,&Gender,TemID,&TemGrade);
if(Gender=='M')
{
if(MinGrade > TemGrade)
{
strcpy(ManName,TemName);
strcpy(ManID,TemID);
MinGrade = TemGrade;
}
}
else
{
if(MaxGrade < TemGrade)
{
strcpy(FelName,TemName);
strcpy(FelID,TemID);
MaxGrade = TemGrade;
}
}
}
int complete=1;
if(strcmp(FelID,"")==0)
{
printf("Absent\n");
complete=0;
}
else printf("%s %s\n",FelName,FelID);

if(strcmp(ManID,"")==0)
{
printf("Absent\n");
complete=0;
}
else printf("%s %s\n",ManName,ManID);

if(complete) printf("%d\n",MaxGrade-MinGrade);
else printf("NA\n");
}
return 0;
}