1025 PAT Ranking (25分) 【成绩排名】

题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805474338127872

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately after the test. Now it is your job to write a program to correctly merge all the ranklists and generate the final rank.

Input Specification:

Each input file contains one test case. For each case, the first line contains a positive number N (≤100), the number of test locations. Then N ranklists follow, each starts with a line containing a positive integer K (≤300), the number of testees, and then K lines containing the registration number (a 13-digit number) and the total score of each testee. All the numbers in a line are separated by a space.

Output Specification:

For each test case, first print in one line the total number of testees. Then print the final ranklist in the following format:

#include
#include
#include
using namespace std;struct student
{char id[15]; //准考证号int score; //分数int local_number; //考场号int local_rank; //考场内的排名	
}stu[30010];bool cmp(student a,student b)
{if(a.score!=b.score) return a.score>b.score;else return strcmp(a.id,b.id)<0;
} int main()
{int n; //考场数 int k;int num=0; //总人数 cin>>n;//按考场数遍历 for(int i=1;i<=n;i++){cin>>k; //考场内人数//先输入考场内人员的信息 for(int j=0;j>stu[num].id>>stu[num].score;stu[num].local_number=i;num++;} //然后排序 sort(stu+num-k,stu+num,cmp);//然后定排名 stu[num-k].local_rank=1;for(int j=num-k+1;j

 


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部