求助,50分
查看原帖
求助,50分
1010177
sxms_tanjialei楼主2024/5/2 19:48

只有50分,后面5个点WA了

#include<bits/stdc++.h>
using namespace std;
struct students
{
	int num;   //学生学号
	int c;    //学生语文成绩
	int m;    //学生数学成绩
	int e;    //学生英语成绩
	int zong; //学生总成绩
}st[301];

bool cmp(students x,students y)
{
	return x.zong>y.zong;
}

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		st[i].num=i;
		cin>>st[i].c>>st[i].m>>st[i].e;
		st[i].zong=st[i].c+st[i].m+st[i].e;
	}
	sort(st+1,st+1+n,cmp);//从小到大排序
	for(int i=1;i<=5;i++)
		cout<<st[i].num<<' '<<st[i].zong<<endl;
	return 0;
}
2024/5/2 19:48
加载中...