1. 程式人生 > >PAT 甲級 A1036 (2019/02/08)

PAT 甲級 A1036 (2019/02/08)

int truct printf cor emp info || nbsp har

 1 #include<cstdio>
 2 struct stu_info{
 3     char name[20];
 4     char id[20];
 5     int score;
 6 }M, F, temp;
 7 void init(){
 8     M.score = 101;
 9     F.score = -1;    
10 }
11 int main(){
12     init();
13     int k; char gender;
14     scanf("%d", &k);
15     for(int
i = 0; i < k; i++){ 16 scanf("%s %c %s %d", temp.name, &gender, temp.id, &temp.score); 17 if(gender == M && temp.score < M.score) M = temp; 18 if(gender == F && temp.score > F.score) F = temp; 19 } 20 if(F.score == -1) printf("
Absent\n"); 21 else printf("%s %s\n",F.name,F.id); 22 if(M.score == 101) printf("Absent\n"); 23 else printf("%s %s\n",M.name,M.id); 24 if(F.score == -1 || M.score == 101) printf("NA"); 25 else printf("%d",F.score-M.score); 26 return 0; 27 }

PAT 甲級 A1036 (2019/02/08)