当前位置:网站首页>C243: examination ranking
C243: examination ranking
2022-07-27 20:01:00 【Qiangan】
Problem description
There is 5 Problem sum 1 Additional questions , The highest score per question 20 branch , The total score is calculated as the sum of the scores of all topics . Give the data of a group of candidates , Rank them from high to low according to the total score , If the total score is the same, the one with higher score according to the additional questions will be preferred .
Enter description
The first line is an integer N, Indicates the number of candidates (N Less than 100), Back N Behavioral candidate data , Each line contains the candidate's name ( Length not exceeding 20 Characters ) as well as 6 An integer separated by spaces , It represents the scores of questions 1 to 5 and additional questions respectively ( Last item ).
The output shows that
Output sorting results , The name of each candidate 、 Total score 、 Additional questions score , Separate... By spaces .
sample input
3
Jony 18 20 20 20 20 20
Kavin 20 20 20 20 20 18
Kaku 15 15 15 15 15 15
sample output
Jony 118 20
Kavin 118 18
Kaku 90 15
#include<stdio.h>
int main()
{
int n,i,j;
struct stu
{
char m[20];
int f[6];
int z=0;
}a[100],t;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",a[i].m);
for(j=0;j<6;j++)
{
scanf("%d",&a[i].f[j]);
a[i].z+=a[i].f[j];
}
}
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1-i;j++)
{
if(a[j].z<a[j+1].z)
{
t=a[j];a[j]=a[j+1];a[j+1]=t;
}
else if(a[j].z==a[j+1].z)
{
if(a[j].f[5]<a[j+1].f[5])
{
t=a[j];a[j]=a[j+1];a[j+1]=t;
}
}
}
}
for(i=0;i<n;i++)
{
printf("%s %d %d",a[i].m,a[i].z,a[i].f[5]);
if(i!=n-1) printf("\n");
}
return 0;
}
边栏推荐
猜你喜欢
随机推荐
GridView (implement table display icon)
How powerful can top "hackers" be? Internet access without signal, expert: high-end operation!
Built in module 10.18
Container summary
Overview of deep active learning 2020
Detailed interpretation of IEC104 protocol (II) interaction process and protocol analysis
Basic functions of pytorch tensor
文件操作防护
focal loss
C#求完全数,输出水仙花以及类的使用
11.2DHCP
Summenudemo (submenu)
C170:复试筛选
C# 后台GC 的前因后果
常见运算符9.21
归一化(Normalization)和标准化(Standardization)
Common errors reported by pytorch
MVCC的底层原理
聊聊 Redis 是如何进行请求处理
Adults have only one main job, but they have to pay a price. I was persuaded to step back by personnel, and I cried all night









