当前位置:网站首页>C170: retest screening
C170: retest screening
2022-07-27 20:01:00 【Qiangan】
Problem description
After the announcement of the results of the first postgraduate entrance examination, you need to be right m Sort the scores of students , Screen out the former who can enter the retest n Famous student .
The sorting rule is to sort according to the total score first , If the total score is the same, it will be sorted according to the score of English single subject , When the total score and English score are the same, the person with small test number is in the front .
Now we give this m The results of the first postgraduate entrance examination of students , Please screen out those who can enter the re examination n Students and output... In order of ranking from high to low .
Enter description
Input is m+1 That's ok , The first line is two integers m and n, It indicates the total number of people and the number of people who can enter the retest ,m and n Space between ,0<n<m<200.
Next is m Row data , Each line contains three pieces of information , Each represents a student's test number ( Length not exceeding 20 String )、 Total score ( Less than 500 The integer of ) And English single subject scores ( Less than 100 The integer of ), These three items are separated by spaces .
The output shows that
Output the items entering the retest in the order of ranking from high to low n Information about students .
sample input
5 3
XD20160001 330 65
XD20160002 330 70
XD20160003 340 60
XD20160004 310 80
XD20160005 360 75
sample output
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;
}
边栏推荐
- 使用VS编译NCNN
- [论文阅读] Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation
- C170:复试筛选
- 第2章 入门
- pytorch tensor的基本函数
- Detailed interpretation of IEC104 protocol (II) interaction process and protocol analysis
- 黑客入门教程(非常详细)从零基础入门到精通,看完这一篇就够了。
- C191:密码编译
- New library online | cnopendata detailed address data of all patents in China
- ACL11.12
猜你喜欢

全局函数

Chapter 2 Introduction

Hyperledger caliper is built on fabric for performance test

第2章 入门

Version announcement | Apache Doris 1.1 release version officially released!

22年PMP考试【全真敏捷试题】

ECU的软硬件架构

Radiogroup (radio box)

New library online | cnopendata detailed address data of all patents in China

疫情下我离职一年,收入增长了10倍
随机推荐
Container summary
C#网络应用编程,实验一:WPF练习
Radiogroup (radio box)
An unknown fastcgi error occurred in IIS: 0x80070005
函数优先顺序
Detailed introduction to common coordinate system of cesium
文件操作防护
Sharepreference (storage)
11.2DHCP
第3章 基本操作
10.31静态路由的扩展配置
Object常用方法学习【clone和equals】
pytorch lstm+attention
Datepicker and TimePicker
2022爱分析·智慧社区厂商全景报告 厂商征集
化工巨头巴斯夫&Pasqal:利用量子神经网络优化天气预报
【C#网络应用编程】实验3:进程管理练习
ECU的软硬件架构
Cesium常用坐标系详细介绍
transformers-bert