文章

193

粉丝

0

获赞

756

访问

27.7k

头像
成绩排序2.0 题解:
P1159 清华大学上机题
发布于2026年3月15日 17:09
阅读数 34

#include<bits/stdc++.h>
using namespace std;

struct node{
	int num,score;
};	
bool cmp(node a,node b){
	if(a.score == b.score)
		return a.num < b.num;
	else
		return a.score < b.score;	
}	
int main(){
	int n;
	cin >> n;
	vector<node> stu(n);
	for(int i=0;i<n;i++)
		cin >> stu[i].num >> stu[i].score;
	sort(stu.begin(),stu.end(),cmp);
	for(auto it:stu)
		cout << it.num << " " << it.score << endl;
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发