当前位置:网站首页>C语言 成绩排名
C语言 成绩排名
2022-06-30 01:25:00 【Martin の Blog】

算法设计思路
- 定义一个结构体,其中包括:name、id以及score
- 对score进行排序,找出最大和最小值
- 按照最大和最小值打印name和id
代码
#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;
}

边栏推荐
猜你喜欢

The listing of Symantec electronic sprint technology innovation board: it plans to raise 623million yuan, with a total of 64 patent applications

The 8th "Internet +" competition - cloud native track invites you to challenge

What is digital garbage? Follow the world's first AI artist to explore meta carbon Art

In depth analysis of a large number of clos on the server_ The root of wait

Resizekit2.net size and resolution independent

Online sql to CSV tool

numpy的索引和图片的索引一样吗?

Seata 与三大平台携手编程之夏,百万奖金等你来拿

Understand the module function of MES management system

js返回内容被unicode编码
随机推荐
Analysis of natural frequency and buckling load of cylinder by finite element method
C语言 一元多项式求导
Taguchi experimental method
Solution to webkitformboundaryk in post request
【535. TinyURL 的加密与解密】
How to refuse the useless final review? Ape tutoring: it is important to find a suitable review method
首届技术播客月开播在即
MES管理系统功能模块之质量管理
Sentinel source code analysis Part 8 - core process - sphu Entry current limiting execution
Embedded exit (review and release)
[Thesis Writing] English thesis writing guide
Precautions for postoperative fundus hemorrhage / / must see every day
Seata 與三大平臺攜手編程之夏,百萬獎金等你來拿
Is the course of digging money reliable and safe to open an account?
Unity编辑器随机生成物体,更换场景之后物体丢失问题解决
Stimulus reports reporting tool, stimulus creates and builds reports
快手伸手“供给侧”,找到直播电商的“源头活水”?
Ansible ad-hoc temporary command
Seata 与三大平台携手编程之夏,百万奖金等你来拿
Varnish 基础概览3