当前位置:网站首页>1015 theory of virtue and talent
1015 theory of virtue and talent
2022-06-29 04:11:00 【Lele ~ll】
Sima Guang, a historian of the Song Dynasty 《 History As A Mirror 》 There is a famous passage in “ On virtue and talent ”:“ That's why we call it a saint , It's a fool to have both talent and morality , Virtue is a gentleman , Cai Shengde is called villain . The art of taking people , Not a saint , It's a gentleman , It's better to be a villain , If you don't get a fool .”
Here are the scores of a group of candidates , Please give the admission ranking according to Sima Guang's theory .
Input format :
The first line of input is given 3 A positive integer , Respectively :N(≤105), That is, the total number of candidates ;L(≥60), For the lowest score , That is, both moral and talent scores are no less than L Candidates are eligible to be considered for Admission ;H(<100), For the priority admission line —— Those whose moral and talent scores are not lower than this line are defined as “ Just do everything ”, Such candidates are ranked from high to low according to the total score of virtue and talent ; The candidates who can't get the grade but get the priority admission line belong to “ Deshengcai ”, Also sort by total score , But after the first category of candidates ; Both moral and talent scores are lower than H, But candidates with a moral score of no less than talent belong to “ Both talent and morality ” But there is still “ Deshengcai ” person , Sort by total score , But after the second category of candidates ; Others reach the lowest line L The candidates are also ranked according to the total score , But after the third category of candidates .
And then N That's ok , Each line gives the information of one candidate , Include : Ticket number Defen Talent , among Ticket number by 8 An integer , Virtue and talent are divided into intervals [0, 100] The whole number inside . Numbers are separated by spaces .
Output format :
The first line of the output first gives the number of candidates who have reached the lowest score line M, And then M That's ok , Each line outputs the information of one candidate according to the input format , Candidates are sorted from high to low according to the rules described in the input . When there are more than one examinee in a certain category, they always share the same score , In descending order of virtue ; If the German points are also tied , Then it will be output in ascending order of the admission certificate number .
sample input :
14 60 80
10000001 64 90
10000002 90 60
10000011 85 80
10000003 85 80
10000004 80 85
10000005 82 77
10000006 83 76
10000007 90 78
10000008 75 79
10000009 59 90
10000010 88 45
10000012 80 100
10000013 90 99
10000014 66 60
sample output :
12
10000013 90 99
10000012 80 100
10000003 85 80
10000011 85 80
10000004 80 85
10000007 90 78
10000006 83 76
10000005 82 77
10000002 90 60
10000014 66 60
10000008 75 79
10000001 64 90The code is as follows :
#include<stdio.h>
typedef struct {
int id;
int de;// Virtue
int cai;// only
int sum;
}STU;
void prin(STU a[100000], int n)
{
int i, j;
// int k = n - 1;
for (i = 0; i < n - 1; i++)
{
int flag = 0;
for (j = 0; j < n-i-1; j++)
{
if (a[j].sum < a[j + 1].sum)
{
STU f = a[j];
a[j] = a[j + 1];
a[j + 1] = f;
flag = 1;
}
else if (a[j].sum == a[j + 1].sum && a[j].de < a[j + 1].de)
{
STU f = a[j];
a[j] = a[j + 1];
a[j + 1] = f;
flag = 1;
}
else if (a[j].sum == a[j + 1].sum && a[j].de == a[j + 1].de&&a[j].id>a[j+1].id)
{
STU f = a[j];
a[j] = a[j + 1];
a[j + 1] = f;
flag = 1;
}
//k = pos;
}
if (flag == 0)
{
break;
}
}
for (i = 0; i < n; i++)
{
printf("%d %d %d\n", a[i].id, a[i].de, a[i].cai);
}
}
int main()
{
int num, min, good;// Number of candidates , Minimum admission line , Priority admission line
int i, j, k;// Service for circulation
int number = 0;
int id, de, cai;
STU a[10000]; int an = 0;//de>good && cai >good
STU b[10000]; int bn = 0;//de>=good && cai<good
STU c[10000]; int cn = 0;//de>=min &&cai >=min &&de>=cai
STU d[10000]; int dn = 0;//de>=min&&cai>=min
scanf("%d %d %d", &num, &min, &good);
for (i = 0; i < num; i++)
{
scanf("%d %d %d", &id, &de, &cai);
if (de >= good && cai >= good)
{
a[an].id = id; a[an].de = de; a[an].cai = cai;
a[an].sum = de + cai;
an++; number++;
}
else if (de >= good && cai < good && cai >= min)
{
b[bn].id = id; b[bn].de = de; b[bn].cai = cai;
b[bn].sum = de + cai;
bn++; number++;
}
else if (de >= min && cai >= min && de >= cai)
{
c[cn].id = id; c[cn].de = de; c[cn].cai = cai;
c[cn].sum = de+cai;
cn++; number++;
}
else if (de >= min && cai >= min)
{
d[dn].id = id; d[dn].de = de; d[dn].cai = cai;
d[dn].sum = de + cai;
dn++; number++;
}
}
printf("%d\n", number);
prin(a, an);
prin(b, bn);
prin(c, cn);
prin(d, dn);
return 0;
}
边栏推荐
- String differences between different creation methods
- Baidu AI Cloud service grid product CSM release 𞓜 hot public beta
- Establishment of small and medium-sized enterprise network
- 情绪的变化需要控制
- webassembly学习-动态链接
- 赚钱的5个层次,你在哪一层?
- 技术:如何设计zkVM电路
- 多机局域网办公神器 rustdesk 使用强推!!!
- Error accessing database
- 044. (2.13) add value to yourself
猜你喜欢
![[C language] explain the thread exit function pthread_ exit](/img/fb/96db1c712370dbb216a06440ecdc5e.png)
[C language] explain the thread exit function pthread_ exit

基于xlsx的B+树索引实现

c语言 --- 分支结构

If you choose the right school, you can enter Huawei as a junior college. I wish I had known

Influence of air resistance on the trajectory of table tennis

IDEA修改jvm内存

Remote connection of raspberry pie in VNC Viewer Mode

Rapid development project -vscode plug-in

sql两列变为多行过滤显示

为什么说测试岗位是巨坑?8年测试人告诉你千万别上当
随机推荐
Analysis of moudo Network Library
Qtableview gets all currently selected cells
我的创作纪念日
Influence of air resistance on the trajectory of table tennis
项目开发修养
Canoe- how to parse messages and display information in the trace window (use of program node and structure type system variables)
Establishment of small and medium-sized enterprise network
Nuxt - set SEO related tags, page titles, icons, etc. separately for each page (page configuration head)
请问大佬,Oracle CDC报错 Call snapshotState on closed sou
【C语言】开启一个线程
二叉树序列化与反序列化(leetcode(困难))
Nuxt - 每个页面单独设置 SEO 相关标签及网页标题、图标等(页面配置 head)
1015 德才论
I came from a major, so I didn't want to outsource
Implementation of b+ tree index based on xlsx
在命令行登录mysql数据库以及查看版本号
NotImplementedError: Could not run torchvision::nms
【FPGA数学公式】使用FPGA实现常用数学公式
[C language] explain the thread exit function pthread_ exit
CANoe-如何在Trace窗口解析报文并显示信息(Program Node和结构体类型系统变量的使用)