文章

81

粉丝

0

获赞

282

访问

11.0k

头像
成绩排序2.0 题解:
P1159 清华大学上机题
发布于2025年3月21日 15:59
阅读数 77

#include<bits/stdc++.h>
using namespace std;
struct student{
	int co;
	int score;
}stu[1000];
bool cmp(student a,student b){
	if(a.score==b.score)
	{return a.co < b.co;
	}
	else {
		return a.score < b.score;
	}
}
int main(){
	int n,i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>stu[i].co>>stu[i].score;
	}
	sort(stu,stu+n,cmp);
	for(i=0;i<n;i++){
		cout<<stu[i].co<<" "<<stu[i].score<<endl;
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发