90分求救!
查看原帖
90分求救!
1248477
zhujingy楼主2024/4/4 20:59

第八个点错了

#include<bits/stdc++.h>

using namespace std;

struct student{
	int n;
	int yuwen,shuxue,yingyu;
	int zongfen;
}st[305];

bool cmp(student a,student b)
{
	if(a.zongfen>b.zongfen)return 1;
	else if(a.zongfen==b.zongfen&&a.yuwen>b.yuwen)return 1;
	return 0;
}

int main()
{
	int m;
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>st[i].yuwen>>st[i].shuxue>>st[i].yingyu;
		st[i].n=i;
		st[i].zongfen=st[i].yuwen+st[i].shuxue+st[i].yingyu;
	}
	sort(st+1,st+m+1,cmp);
	for(int i=1;i<=5;i++)
	{
		cout<<st[i].n<<""<<st[i].zongfen<<endl;
	}
	return 0;
}
2024/4/4 20:59
加载中...