PAT A1025 英语翻译(含c语言题解)

PAT A1025 英语翻译(含c语言题解),第1张

PAT A1025 英语翻译(含c语言题解)

英语本来就不好,就用pat来练习英文翻译,

A1025 导航

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University.

这句话含义是:PAT是一个由浙江大学计算机科学技术系组织的

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.

针对每一个样例,第一行包含整数N,不会超过100,和测试地点的编号

Then N ranklists follow, each starts with a line containing a positive integer K (≤300),

然后N个排名紧随其后,每个开始都是包含一个正整数K的测试序号(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.

然后k个13位数字的注册号,以及每个测试的总得分,所有的数据在一行,并且有空格隔开

词汇积累:
Specification 规范n.
number of test locations 测试地点
registration number 注册号
输出

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:

然后打印最后的排名格式

registration_number final_rank location_number local_rank

注册号 最后排名 测试地点的标号 测试地点的排名

The locations are numbered from 1 to N. The output must be sorted in nondecreasing order of the final ranks. The testees with the same score must have the same rank, and the output must be sorted in nondecreasing order of their registration numbers.

测试地点是1-N,输出必须是最终排名的非降序,测试人成绩相同时必须有同排名,然后按照测试号非降序排序

代码思路

代码思路主要是先获得输入,获得一轮输入后先排序,然后拍完序最后输入完在大循环外排序。

完整代码

#include
#include //需要引入的库
#include 
#include 

using namespace std;
struct Student{
    char id[15];//准考证号
    int score; // 最后得分
    int location_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,k = 0,num = 0;
    scanf("%d",&n);
    for(int i =1;i<=n;i++){
        scanf("%d",&k);
        for(int j= 0;j0 && stu[i].score != stu[i-1].score){
            r = i+1;
        }
        printf("%s ",stu[i].id);
        printf("%d %d %dn",r,stu[i].location_number,stu[i].local_rank);
    }
    return 0;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5702866.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存