SQRW @ 2023-12-24 19:48:56
using namespace std; struct { string a; int b,c,d; }a[106]; int n; int main (){ cin>>n; for(int i=1;i<=n;i++)cin>>a[i].a>>a[i].b>>a[i].c>>a[i].d; for(int i=1;i<n;i++){ for(int j=1;j<=n-i;j++){ if(a[j].b>a[j+1].b)swap(a[j],a[j+1]); else if(a[j].c>a[j+1].c&&a[j].b==a[j+1].b)swap(a[j],a[j+1]); else if(a[j].d>=a[j+1].d&&a[j].b==a[j+1].b&&a[j].c==a[j+1].c)swap(a[j],a[j+1]); } } for(int i=1;i<=n;i++)cout<<a[i].a<<endl; return 0; }
#include<bits/stdc++.h>
using namespace std;
struct {
string a;
int b,c,d;
}a[106];
int n;
int main (){
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i].a>>a[i].b>>a[i].c>>a[i].d;
for(int i=1;i<n;i++){
for(int j=1;j<=n-i;j++){
if(a[j].b>a[j+1].b)swap(a[j],a[j+1]);
else if(a[j].c>a[j+1].c&&a[j].b==a[j+1].b)swap(a[j],a[j+1]);
else if(a[j].d>=a[j+1].d&&a[j].b==a[j+1].b&&a[j].c==a[j+1].c)swap(a[j],a[j+1]);
}
}
for(int i=1;i<=n;i++)cout<<a[i].a<<endl;
return 0;
}
by SQRW @ 2023-12-24 19:49:37
只有64
by Syncc @ 2023-12-24 19:53:48
要sort
by 6syano @ 2023-12-24 19:55:47
冒泡排序的话第二个循环应该是for(int j=i+1;j<=n;j++){
by WPenghan @ 2024-01-31 15:14:45
少个sort