PAT-A1036

来源:互联网 发布:淘宝服装店铺文案 编辑:程序博客网 时间:2024/04/30 14:39
#include<stdio.h>#include<string.h>struct pnode{char name[12], ID[12];char gender;int grade;}temp,high, low;int main(){int i, n;high.grade=-1; low.grade=200;scanf("%d",&n);for(i=0;i<n;i++){scanf("%s %c %s %d", temp.name,&temp.gender,temp.ID,&temp.grade);if(temp.gender=='F' && temp.grade>high.grade)      {high.grade=temp.grade;  strcpy(high.ID,temp.ID);  strcpy(high.name,temp.name);}if(temp.gender=='M' && temp.grade<low.grade)      {low.grade=temp.grade;   strcpy(low.ID,temp.ID);  strcpy(low.name,temp.name);}}if(high.grade!=-1)printf("%s %s\n",high.name,high.ID);else printf("Absent\n");if(low.grade!=200)printf("%s %s\n",low.name,low.ID);else printf("Absent\n");if(high.grade!=-1&&low.grade!=200)printf("%d\n",high.grade-low.grade);else printf("NA\n");return 0;}

0 0