当前位置:网站首页>C170:复试筛选
C170:复试筛选
2022-07-27 17:17:00 【千干】
问题描述
考研初试成绩公布后需要对m个学生的成绩进行排序,筛选出可以进入复试的前n名学生。
排序规则为首先按照总分排序,总分相同则按英语单科成绩排序,总分和英语成绩也相同时考号小者排在前面。
现给出这m个学生的考研初试成绩,请筛选出可以进入复试的n名学生并按照排名从高到低的顺序依次输出。
输入说明
输入为m+1行,第一行为两个整数m和n,分别表示总人数和可以进入复试人数,m和n之间用空格分隔,0<n<m<200。
接下来为m行数据,每行包括三项信息,分别表示一个学生的考号(长度不超过20的字符串)、总成绩(小于500的整数)和英语单科成绩(小于100的整数),这三项之间用空格分隔。
输出说明
按排名从高到低的顺序输出进入复试的这n名学生的信息。
输入样例
5 3
XD20160001 330 65
XD20160002 330 70
XD20160003 340 60
XD20160004 310 80
XD20160005 360 75
输出样例
XD20160005 360 75
XD20160003 340 60
XD20160002 330 70
#include<stdio.h>
int main()
{
int m,n,i,j;
struct stu
{
char h[20];
int a;
int e;
}l[200],t;
scanf("%d %d",&m,&n);
for(i=0;i<m;i++)
{
scanf("%s %d %d",l[i].h,&l[i].a,&l[i].e);
}
for(i=0;i<m-1;i++)
{
for(j=0;j<m-1-i;j++)
{
if(l[j].a<l[j+1].a)
{
t=l[j];l[j]=l[j+1];l[j+1]=t;
}
else if(l[j].a==l[j+1].a)
{
if(l[j].e<l[j+1].e)
{
t=l[j];l[j]=l[j+1];l[j+1]=t;
}
else if(l[j].e==l[j+1].e)
{
if(l[j].h>l[j+1].h)
{
t=l[j];l[j]=l[j+1];l[j+1]=t;
}
}
}
}
}
for(i=0;i<n;i++)
{
printf("%s %d %d",l[i].h,l[i].a,l[i].e);
if(i!=n-1) printf("\n");
}
return 0;
}
边栏推荐
- Detailed explanation of the underlying data structure of redis
- NAT 11.16
- GridView(实现表格显示图标)
- 深度主动学习综述2020
- 11.5.OSPF
- [daily accumulation - 07] CUDA multi version switching
- Sharepreference (storage)
- [RCTF2015]EasySQL-1|SQL注入
- ContextMenu (context menu)
- [basic knowledge of deep learning - 48] characteristics of Bayesian network
猜你喜欢

Virtualbox:ssh connection

Complex number proof of solvability of regular 17 sided ruler and gauge drawing

focal loss

ContentProvider of four components

成年人只有一份主业是要付出代价的,被人事劝退后,我哭了一整晚

Hyperledger caliper is built on fabric for performance test

ArrayAdapter(数组适配器)与SimpleAdapter(简单适配器)

Togglebutton (button switch)

JS 寻找所有节点sibling childNodes children

Sharepreference (storage)
随机推荐
【深度学习基础知识 - 43】优势比的概念
[basic knowledge of in-depth learning - 40] Why does CNN have more advantages than DNN in the field of images
Pytorch reports CUDA error: no kernel image is available for execution on the device error
MySQL time zone problem
王牌代码静态测试工具Helix QAC 2022.2中的新增功能(2)
被动收入:回归原始且安全的两种赚取方法
It is said that Apple plans to buy some JDI factories with us $200million
Introduction to socke programming
JS 事件监听 鼠标 键盘 表单 页面 onclick onkeydown onChange
Sharepreference (storage)
【日常积累 - 06】查看cuda和cudnn版本
Intent (whether there is return value to jump)
Install Talib Library under Anaconda
Object常用方法学习【clone和equals】
【深度学习基础知识 - 41】深度学习快速入门学习资料
Release Samsung 3J1 sensor: the code implies that the safety of pixel 7 face recognition will be greatly increased
The first in the field of mobile phone chip design in the world! Ziguang zhanrui won the international certification of tmmi4
[basic knowledge of deep learning - 42] detailed explanation of logistic regression
Virtualbox:ssh connection
pytorch lstm+attention