C语言 成绩排名
算法設(shè)計(jì)思路
代碼
#include <stdio.h>struct student{char name[100];char id[100];int score; };int main(){struct student st[100], max, min;max.score = -1;min.score = 100;int n, i;scanf("%d", &n);for(i=0; i<n; i++){scanf("%s %s %d", st[i].name, st[i].id, &st[i].score);}for(i=0; i<n; i++){if(st[i].score > max.score){max = st[i];}if(st[i].score < min.score){min = st[i];}}printf("%s %s\n%s %s\n", max.name, max.id, min.name, min.id);return 0; }總結(jié)
- 上一篇: 《论文代码》CARE: Commonse
- 下一篇: 日本語トレーニング(三)