Hujiaming17 @ 2024-07-08 20:51:36
#include<bits/stdc++.h>
using namespace std;
struct st{
int num;
int ch,ma,en;
int score;
}a[305];
bool cmp(st x,st y){
if(x.score>y.score){
return 1;
}
else if(x.score==y.score){
if(x.ch>y.ch){
return 1;
}
else if(x.ch=y.ch){
if(x.num<y.num){
return 1;
}
}
}
return 0;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].ch>>a[i].ma>>a[i].en;
a[i].score=a[i].ch+a[i].ma+a[i].en;
a[i].num=i;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].num<<" "<<a[i].score<<endl;
}
return 0;
}
by tylerlong @ 2024-07-08 21:07:32
#include<bits/stdc++.h>
using namespace std;
int n;
struct stu{
int a,b,c,d=0,e;
}s[305];
bool cmp(stu a,stu b){
if(a.d>b.d)return true;
else if(a.d==b.d){
if(a.a>b.a)return true;
else if(a.a==b.a){
if(a.e<b.e)return true;
else return false;
}
else return false;
}
else return false;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>s[i].a>>s[i].b>>s[i].c;
s[i].e=i;
s[i].d=s[i].a+s[i].b+s[i].c;
}
sort(s+1,s+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<s[i].e<<' '<<s[i].d<<endl;
}
return 0;
}
by tylerlong @ 2024-07-08 21:08:23
牢大!!!我想你了!!!
by tylerlong @ 2024-07-08 21:08:58
科比黑曼巴!!!
by dirty_1one @ 2024-07-09 14:47:44
@Hujiaming17
#include<bits/stdc++.h>
using namespace std;
int n;
struct xiaoxuesheng{
int z/*yw*/,x/*sx*/,c/*yy*/;
int id,sum;
}a[305];
bool cmp(xiaoxuesheng a, xiaoxuesheng b){
if(a.sum!=b.sum)
return a.sum>b.sum;
if(a.z!=b.z)
return a.z>b.z;
return a.id<b.id;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].z>>a[i].x>>a[i].c;
a[i].id=i;
a[i].sum=a[i].x+a[i].z+a[i].c;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].id<<" "<<a[i].sum<<endl;
}
}
by Hujiaming17 @ 2024-07-09 18:20:14
@tylerlong 懂了,已互关,感谢大牢!!!
by Hujiaming17 @ 2024-07-09 18:21:19
@xiaozhang0124 已懂,必壶关!!! 感谢!