yuanzongzi799 @ 2024-11-15 21:01:19
#include <bits/stdc++.h>
using namespace std;
struct stu{
int chi,mat,eng,xuehao,cme;
}xh[303];//结构体
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
xh[i].xuehao=i;
cin>>xh[i].chi>>xh[i].mat>>xh[i].eng;
xh[i].cme=xh[i].chi+xh[i].mat+xh[i].eng;
}//读入
for(int i=1;i<=n-1;i++)
{
for(int j=1;j<=n-i;j++)
{
if(xh[j].cme<xh[j+1].cme)
{
swap(xh[j],xh[j+1]);
}
if(xh[j].cme==xh[j+1].cme)
{
if(xh[j].chi<xh[j+1].cme)
{
swap(xh[j],xh[j+1]);
}
if(xh[j].mat<xh[j+1].mat)
{
swap(xh[j],xh[j+1]);
}
if(xh[j].eng<xh[j+1].eng)
{
swap(xh[j],xh[j+1]);
}//一堆判断
}
}
}
for(int i=1;i<=5;i++)
{
cout<<xh[i].xuehao<<" "<<xh[i].cme<<"\n";
}//打印
}
by yuanzongzi799 @ 2024-11-15 21:07:39
要求:在原代码的基础上修改
by JANMESCREEY1 @ 2024-11-17 14:47:07
jinitaimei