7-8 德才论 (25 分)(C语言实现)

7-8 德才论 (25 分)

宋代史学家司马光在《资治通鉴》中有一段著名的“德才论”:“是故才德全尽谓之圣人,才德兼亡谓之愚人,德胜才谓之君子,才胜德谓之小人。凡取人之术,苟不得圣人,君子而与之,与其得小人,不若得愚人。”现给出一批考生的德才分数,请根据司马光的理论给出录取排名。输入格式:
输入第一行给出 3 个正整数,分别为:N(≤105
​​ ),即考生总数;L(≥60),为录取最低分数线,即德分和才分均不低于 L 的考生才有资格被考虑录取;H(<100),为优先录取线——德分和才分均不低于此线的被定义为“才德全尽”,此类考生按德才总分从高到低排序;才分不到但德分到线的一类考生属于“德胜才”,也按总分排序,但排在第一类考生之后;德才分均低于 H,但是德分不低于才分的考生属于“才德兼亡”但尚有“德胜才”者,按总分排序,但排在第二类考生之后;其他达到最低线 L 的考生也按总分排序,但排在第三类考生之后。随后 N 行,每行给出一位考生的信息,包括:准考证号、德分、才分,其中准考证号为 8 位整数,德才分为区间 [0, 100] 内的整数。数字间以空格分隔。输出格式:
输出第一行首先给出达到最低分数线的考生人数 M,随后 M 行,每行按照输入格式输出一位考生的信息,考生按输入中说明的规则从高到低排序。当某类考生中有多人总分相同时,按其德分降序排列;若德分也并列,则按准考证号的升序输出。输入样例:
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
输出样例:
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 90
#include<stdio.h>
#include<stdlib.h>
struct node{int str;int a,b,c;
}ch1[100001],ch2[100001],ch3[100001],ch4[100001];int cmp(const void *c,const void * d){struct node gan1 = (*(struct node*)c); struct node gan2 = (*(struct node*)d);if (gan1.c>gan2.c) return -1;if (gan1.c==gan2.c){if (gan1.a>gan2.a) return -1;else if (gan1.a==gan2.a) {if (gan1.str<gan2.str) return -1;}} return 1;
}int main()
{int n,L,h,cou=0;scanf("%d %d %d",&n,&L,&h);int h1=0,h2=0,h3=0,h4=0;if (n==0) return 0;while (n--){int str;int a,b;scanf("%d %d %d",&str,&a,&b);if (a>=h) {if (b>=h){ch1[h1].str=str;ch1[h1].a=a;ch1[h1].b=b;ch1[h1].c=a+b;h1++;}else if (b>=L){ch2[h2].str=str;ch2[h2].a=a;ch2[h2].b=b;ch2[h2].c=a+b;h2++;}}else if (a>=L){if (b>=L){if (a>=b){ch3[h3].str=str;ch3[h3].a=a;ch3[h3].b=b;ch3[h3].c=a+b;h3++;}else{ch4[h4].str=str;ch4[h4].a=a;ch4[h4].b=b;ch4[h4].c=a+b;h4++;}}}}qsort(ch1,h1,sizeof(struct node),cmp);qsort(ch2,h2,sizeof(struct node),cmp);qsort(ch3,h3,sizeof(struct node),cmp);qsort(ch4,h4,sizeof(struct node),cmp);printf("%d\n",h1+h2+h3+h4);for (int i=0;i<h1;i++){printf("%d %d %d\n",ch1[i].str,ch1[i].a,ch1[i].b);}for (int i=0;i<h2;i++){printf("%d %d %d\n",ch2[i].str,ch2[i].a,ch2[i].b);}for (int i=0;i<h3;i++){printf("%d %d %d\n",ch3[i].str,ch3[i].a,ch3[i].b);}for (int i=0;i<h4;i++){printf("%d %d %d\n",ch4[i].str,ch4[i].a,ch4[i].b);}return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/428768.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

899. 编辑距离

编辑距离 #include <iostream> #include <cstring> #include <algorithm> using namespace std; int f[1001][1001]; int main() {char ch[1001][13];int n, m;cin >> n >> m;for (int i 0; i < n; i){scanf("%s",ch[i]1);}while…

282. 石子合并

石子合并 #include<algorithm> #include<iostream> using namespace std; const int N 303; int f[N][N]; int s[N]; int main() {int n;cin>>n;for (int i1;i<n;i) cin>>s[i],s[i]s[i-1];for (int len 2;len<n;len)//len长度{for (int i1;il…

868. 筛质数

筛质数 埃及筛法&#xff1a; #include<iostream> #include<cstring> #include<algorithm> using namespace std; int main() {int n,cnt0;bool p[1000010];memset(p,true,sizeof(p));cin>>n;for (int i1;i<n;i){if (p[i]true) cnt;for (int j ii…

870. 约数个数

约数个数 约数个数就是所有数的质因子的个数加一相乘 #include <iostream> #include <set> #include <map> #include <cmath> using namespace std; const int mod 1e9 7; int main() {map<int, int> mp;int n, m;cin >> n;while (n--)…

900. 整数划分

整数划分 两种方案&#xff1a; 第一种&#xff1a;f[i][j] f[i-1][j-1]f[i-j][j]//i表示数量&#xff0c;j表示分几个数 #include <iostream> using namespace std; const int N 1050; const int mod 1e9 7; int f[N][N]; int main() {int n;cin >> n;f[0][0…

3617. 子矩形计数

子矩形计数 #include <iostream> #include <cmath> using namespace std; int a[40041], b[40041]; //int num1[40041],num2[40041]; pair<int, int> f[40041]; int main() {int n, m, k;int num;cin >> n >> m >> k;int cou1 0, cou2 …

常用的一些表和字段

1.【VBAK:销售凭证】 字段&#xff1a;vbeln(销售凭证)、erdat(创建日期)、ername(创建者)、auart(销售类型)、bstnk(采购订单)、bsark(采购订单类型)、bstdk(采购日期)2.【VBAP:销售凭证行项目】 字段&#xff1a;vbeln(销售凭证)、posnr(项目)、matnr(物料)、werks(工厂)、lg…

手风琴案例jquery写法

今天我用jquary来写一下手风琴案例&#xff0c;这个案例在平时的项目中很经常会见到&#xff0c;要想实现效果用jquary来写其实很简单&#xff0c;其实一句话就是jquary的方法的调用。 首先我们先来分析一下手风琴案例实际实现的效果&#xff0c;就是点击当前的标题&#xff0c…

801. 二进制中1的个数

二进制中1的个数 #include<iostream> using namespace std; int h; int main() {int n,num;cin>>n;for (int i0;i<n;i){cin>>num;int cou 0;for (int i0;i<31;i){h num>>i&1;if (h1) cou;}cout<<cou<<" ";} }

D. Omkar and Medians

D. Omkar and Medians Uh oh! Ray lost his array yet again! However, Omkar might be able to help because he thinks he has found the OmkArray of Rays array. The OmkArray of an array a with elements a1,a2,…,a2k−1, is the array b with elements b1,b2,…,bk su…

元组tuple

另一种有序列表叫元组&#xff1a;tuple。tuple和list非常类似&#xff0c;但是tuple一旦初始化就不能修改&#xff0c;比如同样是列出同学的名字&#xff1a; >>> classmates (Michael, Bob, Tracy)现在&#xff0c;classmates这个tuple不能变了&#xff0c;它也没有…

3493. 最大的和

最大的和 滑动窗口 #include <iostream> #define int long long using namespace std; signed main() {int n, k, sum 0, a[101001], b[100101], c[100101];cin >> n >> k;for (int i 1; i < n; i){cin >> a[i];}for (int i 1; i < n; i){ci…

delphi ---ttoolbar,ttoolbutton

1、button style&#xff1a;tbsButton&#xff0c;tbsCheck&#xff0c;tbsDivider&#xff0c;tbsDropDown&#xff0c;tbsSeparator&#xff0c;tbsTextButton tbsButton&#xff1a;普通的控件 tbsSeparator&#xff1a;用作分隔 tbsDropDown&#xff1a;下拉控件&#xff…

3481. 阶乘的和

阶乘的和 #include <iostream> #include <unordered_set> using namespace std; unordered_set<int> S; int main() {int f[11];f[0] 1;for (int i 1; i < 10; i){f[i] f[i - 1] * i;}for (int i 1; i < 1 << 10; i){int s 0;for (int j …

win7下的nginx小demo

一直大概知道nginx怎么玩,但是不看文档又蒙蔽.在这记录一下,以后好查看 下载tomcat,改index.jsp http://tomcat.apache.org/download-80.cgi tomcat9已经出来了,但是自己用了一次,闪退,换tomcat8,开启成功.(tomcat9这个原因有时间在琢磨) 修改tomcat的index.jsp 然后在index.js…

understand的安装

1.win7 64位下安装 1&#xff09;下载Understand.4.0.908.x64.rar。 2&#xff09;解压之&#xff0c;直接运行里面的Understand-4.0.908-Windows-64bit.exe。 3&#xff09;选择如下 之后&#xff0c;点击“Add Eval or SDL (RegCode)”&#xff0c;如下图&#xff1a; 4&…

C. Number of Pairs

C. Number of Pairs You are given an array a of n integers. Find the number of pairs (i,j) (1≤i<j≤n) where the sum of aiaj is greater than or equal to l and less than or equal to r (that is, l≤aiaj≤r). For example, if n3, a[5,1,2], l4 and r7, then t…

A. Arithmetic Array Codeforces Round #726 (Div. 2)

A. Arithmetic Array An array b of length k is called good if its arithmetic mean is equal to 1. More formally, if b1⋯bkk1. Note that the value b1⋯bkk is not rounded up or down. For example, the array [1,1,1,2] has an arithmetic mean of 1.25, which is no…

结对-贪吃蛇游戏-开发环境搭建过程

结对编程成员&#xff1a;赵建辉&#xff0c;马壮 搭建环境&#xff1a; 会 html,css,以及java开发知识。 会应用sublime&#xff0c;dw等编辑软件 编写程序阶段&#xff1a; 1.利用html搭建前端页面&#xff0c;构建游戏的页面框架 2.利用js方面的知识编写贪吃蛇游戏代码转载于…

条件、循环、函数定义 练习

a.五角星 import turtleturtle.color(yellow)turtle.begin_fill()for i in range(5): turtle.forward(100) turtle.right(144)turtle.end_fill() b.同心圆 import turtlefor i in range(5): turtle.up() turtle.goto(0,-20*(i1)) turtle.down() turtle.circle(20*(i1)) c.太阳花…