文章

60

粉丝

361

获赞

41

访问

497.8k

头像
sort
P1159 清华大学上机题
发布于2021年1月12日 20:36
阅读数 8.3k

#include <iostream>
#include <string>
#include <string.h>
#include<algorithm>
using namespace std;

struct student
{
	int id;
	int gore;
}stu[200];

bool compare(student a,student b)
{
	if(a.gore ==b.gore )
		return a.id <b.id ;
	else
		return a.gore <b.gore ;
}

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>stu[i].id >>stu[i].gore;
	sort(stu,stu+n,compare);
	for(int i=0;i<n;i++)
		cout<<stu[i].id <<" "<<stu[i].gore <<endl;
	system("pause");
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发