PAT Basic Level 1004
Posted Ponytai1
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT Basic Level 1004相关的知识,希望对你有一定的参考价值。
1 #include <stdio.h> 2 struct student 3 { 4 int score; 5 char nameChar[11]; 6 char stunoChar[11]; 7 }; 8 int main () 9 { 10 struct student student[1000]; 11 int count = 0; //测试数量 12 scanf("%d",&count); 13 int i = count-1; 14 while (i>=0) 15 { 16 scanf("%s",&student[i].nameChar); 17 scanf("%s",&student[i].stunoChar); 18 scanf("%d",&student[i].score); 19 i--; 20 } 21 int max = student[0].score; 22 int min = student[0].score; 23 int maxNo = 0; 24 int minNo = 0; 25 i = count-1; 26 while (i >= 0) 27 { 28 if(student[i].score>max) 29 { 30 max = student[i].score; 31 maxNo = i; 32 } 33 if(student[i].score<min) 34 { 35 min = student[i].score; 36 minNo = i; 37 } 38 i--; 39 } 40 printf("%s %s\n",student[maxNo].nameChar,student[maxNo].stunoChar); 41 printf("%s %s",student[minNo].nameChar,student[minNo].stunoChar); 42 return 0; 43 44 45 }
以上是关于PAT Basic Level 1004的主要内容,如果未能解决你的问题,请参考以下文章
PAT (Basic Level) Practice 1004 成绩排名
(Python) PAT(Basic Level) Practice 刷题笔记