天梯赛抢红包与PAT judge

本文介绍了一种基于C++的PAT竞赛排名系统实现方案。该系统能够根据参赛者的提交记录,计算每位选手的总分及各题得分,并按特定规则进行排名。包括选手的完全正确题目数量和用户ID作为排名依据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

struct Person{
	int name;//编号 
	int num;// 抢到的红包数 
	int sum;//抢到的红包个数 
}p[10001]; 
bool cmp(Person p1,Person p2){
	if(p1.sum!=p2.sum){
		return p1.sum>p2.sum;
	}
	else if(p1.num!=p2.num){
		return p1.num>p2.num;
	}
	else{
		return p1.name<p2.name;
	}
} 


int main(){
	int t,n,a,b;
	cin>>t;
	
	for(int i=1 ;i<=t ;i++){
		p[i].name = i;//编号初始化 
	}
	
	for(int i=1 ;i<=t ; i++){
		cin>>n;
		while(n--){
			scanf("%d%d",&a,&b);
			p[i].sum-=b;//发红包的人减少的个数 
			p[a].sum += b;
			p[a].num++;
		}
	}
	sort(p+1,p+t+1,cmp);
	for(int i=1 ;i<=t ;i++){
		printf("%d %.2f\n",p[i].name,(double)p[i].sum/100.00);
	}
	
	return 0;
}
10-排序5 PAT Judge   (25分)

The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.

Input Specification:

Each input file contains one test case. For each case, the first line contains 3 positive integers, NNN (≤104\le 10^4104), the total number of users, KKK (≤5\le 55), the total number of problems, and MMM (≤105\le 10^5105), the total number of submissions. It is then assumed that the user id's are 5-digit numbers from 00001 to NNN, and the problem id's are from 1 to KKK. The next line contains KKK positive integers p[i] (i=1, ..., KKK), where p[i] corresponds to the full mark of the i-th problem. Then MMM lines follow, each gives the information of a submission in the following format:

user_id problem_id partial_score_obtained

where partial_score_obtained is either −1-11 if the submission cannot even pass the compiler, or is an integer in the range [0, p[problem_id]]. All the numbers in a line are separated by a space.

Output Specification:

For each test case, you are supposed to output the ranklist in the following format:

rank user_id total_score s[1] ... s[K]

where rank is calculated according to the total_score, and all the users with the same total_score obtain the same rank; and s[i] is the partial score obtained for the i-th problem. If a user has never submitted a solution for a problem, then "-" must be printed at the corresponding position. If a user has submitted several solutions to solve one problem, then the highest score will be counted.

The ranklist must be printed in non-decreasing order of the ranks. For those who have the same rank, users must be sorted in nonincreasing order according to the number of perfectly solved problems. And if there is still a tie, then they must be printed in increasing order of their id's. For those who has never submitted any solution that can pass the compiler, or has never submitted any solution, they must NOT be shown on the ranklist. It is guaranteed that at least one user can be shown on the ranklist.

Sample Input:

7 4 20
20 25 25 30
00002 2 12
00007 4 17
00005 1 19
00007 2 25
00005 1 20
00002 2 2
00005 1 15
00001 1 18
00004 3 25
00002 2 25
00005 3 22
00006 4 -1
00001 2 18
00002 1 20
00004 1 15
00002 4 18
00001 3 4
00001 4 2
00005 2 -1
00004 2 0

Sample Output:

1 00002 63 20 25 - 18
2 00005 42 20 0 22 -
2 00007 42 - 25 - 17
2 00001 42 18 18 4 2
5 00004 40 15 0 25 -
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

struct stu	//学生结构
{
	int id;	//id
	int s[5];	//各题分数,内部从0开始编号
	int score;	//总分
	int pass;	//完全正确题目数
	int ns;	//无提交或无任何通过编译标志,0代表没有通过
	stu()	//初始化
	{
		id=0;score=0;pass=0;ns=0;
		for(int i=0;i<5;i++)
			s[i]=-2;	//由于输出要求,对没有处理过的用-2表示
	}
};

bool cm(const stu &s1,const stu &s2);	//比较

int main()
{
	int n,k,m;
	cin>>n>>k>>m;

	stu *student=new stu [n];	//学生,标号i对应真实id-1
	int p[5];	//分门分数
	
	int i,j;
	for(i=0;i<k;i++)	//输入信息
		scanf("%d",&p[i]);
	int id,p_id,ps;
	for(i=0;i<m;i++)
	{
		scanf("%d %d %d",&id,&p_id,&ps);
		if(ps>student[id-1].s[p_id-1])
			student[id-1].s[p_id-1]=ps;
	}

	for(i=0;i<n;i++)	//计算总分,完全正确题目数,是否需要剔除
	{
		student[i].id=i+1;
		for(j=0;j<k;j++)
		{
			if(student[i].s[j]>=0)
			{
				student[i].score+=student[i].s[j];
				student[i].ns=1;
			}
			if(student[i].s[j]==p[j])
				student[i].pass++;
		}
	}
	stable_sort(student,student+n,cm); //稳定排序,可以免去一次id比较

	int rank=1;	//当前的名次,处理并列用
	int score=student[0].score;	//当前的分数
	for(i=0;i<n;i++)
	{
		if(student[i].ns==0)	//到达无用数据段跳出
			break;
		if(student[i].score!=score)	//不是并列,刷新分数
		{
			rank=i+1;
			score=student[i].score;
		}
		printf("%d %05d %d",rank,student[i].id,student[i].score);	//输出信息
		for(j=0;j<k;j++)
		{
			if(student[i].s[j]>=0)
				printf(" %d",student[i].s[j]);
			else if(student[i].s[j]==-1)
				printf(" 0");
			else
				printf(" -");
		}
		printf("\n");
	}

	delete [] student;

	return 0;
}

bool cm(const stu &s1,const stu &s2)	//按总分和完全正确题目数排序用比较
{
	if(s1.score>s2.score)
		return true;
	else if(s1.score==s2.score)
		return s1.pass>s2.pass;
	else
		return false;
}


内容概要:本文档提供了关于“微型车间生产线的设计生产数据采集试验研究”的毕业设计复现代码,涵盖从论文结构生成、机械结构设计、PLC控制系统设计、生产数据采集分析系统、有限元分析、进度管理、文献管理和论文排版系统的完整实现。通过Python代码和API调用,详细展示了各个模块的功能实现和相互协作。例如,利用SolidWorks API设计机械结构,通过PLC控制系统模拟生产流程,使用数据分析工具进行生产数据的采集和异常检测,以及利用进度管理系统规划项目时间表。 适合人群:具有机械工程、自动化控制或计算机编程基础的学生或研究人员,尤其是从事智能制造领域相关工作的人员。 使用场景及目标:①帮助学生或研究人员快速搭建和理解微型车间生产线的设计实现;②提供完整的代码框架,便于修改和扩展以适应不同的应用场景;③作为教学或科研项目的参考资料,用于学习和研究智能制造技术。 阅读建议:此资源不仅包含详细的代码实现,还涉及多个学科领域的知识,如机械设计、电气控制、数据分析等。因此,在学习过程中,建议读者结合实际操作,逐步理解每个模块的功能和原理,并尝试调整参数以观察不同设置下的系统表现。同时,可以参考提供的文献资料,深入研究相关理论和技术背景。
本次的学生体质健康信息管理网站,按照用户的角色可以分为教师学生,后台设置管理员角色来对学生的信息进行管理。,设计如下: 1、后台管理系统 后台管理系统主要是为该系统的管理员提供信息管理服务的系统,具体包括的功能模块如下: (1)管理员信息管理 (2)教师信息管理 (3)学生信息管理 (4)健康信息统计(图形化进行健康,亚健康等学生的信息数量统计) 2、教师角色的功能模块设计 教师角色所需要的功能模块主要包括了如下的一些内容: (1)个人资料修改 (2)学生体质健康管理:录入相关数据,包括但不限于身高、体重、肺活量、视力等生理指标以及运动能力、身体成分、骨密度等健康指标,并且设置健康,亚健康状态 (3)学生健康建议:根据体质信息,进行学生健康的建议 (4)健康预警:对健康出问题的学生,进行健康预警 (5)饮食和锻炼情况管理,查看 3、学生角色 学生角色可以通过该信息网站看到个人的基本信息,能够看到教师给学生的健康建议等,功能模块设计如下: (1)个人资料修改 (2)我的健康建议查看 (3)我的健康预警 (4)饮食和锻炼情况管理,记录平时的饮食和锻炼情况 完整前后端源码,部署后可正常运行! 环境说明 开发语言:Java后端 框架:ssm,mybatis JDK版本:JDK1.8+ 数据库:mysql 5.7+ 数据库工具:Navicat11+ 开发软件:eclipse/idea Maven包:Maven3.3+ 部署容器:tomcat7.5+
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值