1036 Boys vs Girls 解题代码测试结果问题整理 解题代码 #include<cstdio> struct information { char name[11]; char id[11]; int score; }temp, male, female; int main() { int num; char gender; scanf("%d", &num); male.score = 101; female.score = -1; for (int i = 0; i < num; i++) { scanf("%s %c %s %d", temp.name, &gender, temp.id, &temp.score); if (gender == 'M' && temp.score < male.score) male = temp; if (gender == 'F' && temp.score > female.score) female = temp; } if (female.score == -1) printf("Absent\n"); else printf("%s %s\n", female.name, female.id); if (male.score == 101) printf("Absent\n"); else printf("%s %s\n", male.name, male.id); if (female.score == -1 || male.score == 101) printf("NA"); else printf("%d", female.score - male.score); return 0; } 测试结果 问题整理 1.查找元素。 2.因为修改了一个边界值,导致if判断语句中出现了瑕疵。。