wyx114514 @ 2021-07-22 20:27:00
4个测试点不对```cpp
using namespace std; int main(){ int a[500],b[500],c[500],d[500],n,a1[500],b1[500]; cin>>n; for(int i=1;i<=n;i++){ cin>>b[i]>>c[i]>>d[i]; a[i]=i; } for(int i=1;i<=n;i++){ b1[i]=b[i]+c[i]+d[i]; } for(int i=1;i<=n;i++){ for(int j=1;j<i;j++){ if(b1[i]>b1[j]){ swap(b1[i],b1[j]); swap(a[i],a[j]); } } } for(int i=1;i<5;i++){ if(b1[i]==b1[i+1]){ if(b[i]<b[i+1]){ swap(b1[i],b1[i+1]); swap(a[i],a[i+1]); } } } for(int i=1;i<5;i++){ if(b[i]==b[i+1]&&b1[i]==b1[i+1]){ if(a[i]>a[i+1]){ swap(a[i],a[i+1]); } } } for(int i=1;i<=5;i++){ cout<<a[i]<<" "<<b1[i]<<endl; } }
by 郑墨涵 @ 2021-07-24 11:12:14
朋友你这代码搞的很棒啊
by 郑墨涵 @ 2021-07-24 11:13:31
(或许你可以尝试一下sort加函数?)
by 郑墨涵 @ 2021-07-24 11:16:45
定义个结构体(话说你粘贴成了个啥)
by 郑墨涵 @ 2021-07-24 11:17:31
(聚堆取暖吗)