audvnj @ 2023-07-19 12:25:37
#include<bits/stdc++.h>
using namespace std;
int n[301];
struct qwert
{
int x;
int y;
int s;
int e;
int z(){
return y+s+e;
}
};
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
qwert a;
int b;
cin>>b;
for(int i=1;i<=b;i++)
{
cin>>a.x >>a.y >>a.s>>a.e;
}
for(int i=1;i<=b;i++)
{
sort(a.z(),a.z(),cmp);
}
for(int i=1;i<=b;i++)
{
cout<<a.x <<' '<<a.z() ;
}
}
by FengYuXinMing @ 2023-07-19 12:40:57
#include<bits/stdc++.h>
using namespace std;
struct qwert
{
int x;
int y;
int s;
int e;
int z(){
return y+s+e;
}
};
bool cmp(qwert x,qwert y)
{
return x.z()>y.z();
}
int main()
{
qwert a[1005];
int b;
cin>>b;
for(int i=1;i<=b;i++)
{
cin>>a[i].x >>a[i].y >>a[i].s>>a[i].e;
}
sort(a+1,a+b+1,cmp);
for(int i=1;i<=b;i++)
{
cout<<a[i].x <<' '<<a[i].z();
}
}
看起来舒服多了
by audvnj @ 2023-07-19 12:41:29
@LgxTpre 哎痛苦,老师非让做完题才能走
by FengYuXinMing @ 2023-07-19 12:42:56
@audvnj
往下翻
by audvnj @ 2023-07-19 12:48:36
@ababbjxzt 为甚么sort那要加1
by audvnj @ 2023-07-19 12:51:47
@ababbjxzt 全WA......
#include<bits/stdc++.h>
using namespace std;
int n;
struct qwert
{
int x=0;
int y=0;
int s=0;
int e=0;
int z()
{
return y+s+e;
}
};
bool cmp(qwert a,qwert b)
{
return a.z()>b.z();
}
int main()
{
qwert a[301];
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].x >>a[i].y >>a[i].s>>a[i].e;
}
for(int i=1;i<=n;i++)
{
sort(a+1,a+n+1,cmp);
}
for(int i=1;i<=n;i++)
{
cout<<a[i].x <<' '<<a[i].z() ;
}
}
by audvnj @ 2023-07-19 12:52:45
@ababbjxzt 是不够吗?
by FengYuXinMing @ 2023-07-19 13:00:01
@audvnj 你不要把他套在循环里面啊
by FengYuXinMing @ 2023-07-19 13:05:43
@audvnj 首先啊,这个sort是
但是你写出来的是判断总分而已,所以不符合题目规定,要加一个,如果总分一样,判断语文成绩,语文成绩一样,判断学号
by ATZdhjeb @ 2023-07-19 13:16:34
@ababbjxzt sort
by FengYuXinMing @ 2023-07-19 13:38:34
@ATZdhjeb 突然反应过来了。。。删不了了,就这样吧