当前位置:网站首页>1004 成绩排名 (20 分)
1004 成绩排名 (20 分)
2022-08-09 10:13:00 【Simonqwer】
1004 成绩排名 (20 分)
读入 n(>0)名学生的姓名、学号、成绩,分别输出成绩最高和成绩最低学生的姓名和学号。
输入格式:
每个测试输入包含 1 个测试用例,格式为
第 1 行:正整数 n
第 2 行:第 1 个学生的姓名 学号 成绩
第 3 行:第 2 个学生的姓名 学号 成绩
… … …
第 n+1 行:第 n 个学生的姓名 学号 成绩
其中姓名和学号均为不超过 10 个字符的字符串,成绩为 0 到 100 之间的一个整数,这里保证在一组测试用例中没有两个学生的成绩是相同的。
输出格式:
对每个测试用例输出 2 行,第 1 行是成绩最高学生的姓名和学号,第 2 行是成绩最低学生的姓名和学号,字符串间有 1 空格。
输入样例:
3
Joe Math990112 89
Mike CS991301 100
Mary EE990830 95
输出样例:
Mike CS991301
Joe Math990112
#include<iostream>
using namespace std;
#include<iomanip>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<cstring>
#include<cstdlib>
#include<cmath>
const int N=1e5+10;
struct node
{
string name,num;
int score;
}a[N];
bool cmp(node x,node y)
{
return x.score < y.score;
}
int main()
{
ios_base::sync_with_stdio(0);
int n;
while( cin >> n )
{
int i;
for(i=0;i<n;i++)
cin >> a[i].name >> a[i].num >> a[i].score;
sort(a,a+n,cmp);
cout << a[n-1].name << ' ' << a[n-1].num << endl;
cout << a[0].name << ' ' << a[0].num << endl;
}
return 0;
}
边栏推荐
- Redis + NodeJS 实现一个能处理海量数据的异步任务队列系统
- cannot import name ‘load_offloaded_weights‘ from ‘accelerate.utils‘ (/home/huhao/anaconda3/envs/huha
- Collections and Functions
- By asking where the variables are stored, the shepherd boy laughed and said to use pointers, Go lang1.18 introductory refining tutorial, from Bai Ding to Hongru, the use of go lang type pointers (Poin
- OSCS开源软件安全周报,一分钟了解本周开源软件安全大事
- EndNote使用指南
- 循环嵌套以及列表的基本操作
- Battery modeling, analysis and optimization (Matlab code implementation)
- 蓄电池建模、分析与优化(Matlab代码实现)
- Secretive present: in modern times
猜你喜欢
随机推荐
Redis + NodeJS 实现一个能处理海量数据的异步任务队列系统
StratoVirt 中的虚拟网卡是如何实现的?
[ASM] Bytecode operation MethodVisitor case combat generation object
小程序员的发展计划
使用.NET简单实现一个Redis的高性能克隆版(四、五)
ORA-00600 [16703], [1403], [20]问题分析及恢复
面试官:MySQL 中 update 更新,数据与原数据相同时会执行吗?大部分人答不上来!
Redis 回击 Dragonfly:13 年后,Redis 的架构依然是同类最佳
程序环境和预处理
libavcodec.dll导致游戏不能运行及explorer关闭
Multi-threaded cases - timer
The GNU Privacy Guard
day16_03集合
snmp++编译错误问题解决方法
MySQL索引、视图、设计三范式,通俗易懂,不可错过!
【八大排序④】归并排序、不基于比较的排序(计数排序、基数排序、桶排序)
单元测试1之单元测试的引用
自定义类型:结构体,枚举,联合
tuple dictionary collection
2021-04-26QGIS3.10加载天地图影像(地图瓦片)的一种方法