1183:病人排队

学术版

@[xinbao324](/user/833995) 因为我的能力有限,只能按照我的代码帮你改。 可以用结构体,数组没必要开那么大。 ```cpp #include<bits/stdc++.h> using namespace std; struct sz{ string ld; int age; }all[500],old[500]; int main() { int n; cin >> n; for(int i=0; i<n; i++) { cin >> all[i].ld >> all[i].age ; old[i]=all[i]; } for(int i=0; i<n-1; i++) { for(int j=0;j<=n-i;j++){ if(old[j].age<old[j+1].age ) swap(old[j],old[j+1]); } } for(int j=0; j<n; j++) { if(old[j].age >=60) { cout<<old[j].ld <<endl; } } for(int i=0; i<n; i++) { if(all[i].age <60) { cout<<all[i].ld <<endl; } } return 0; } ```
by WMWD @ 2024-04-21 10:58:47


@[WMWD](/user/1045165) 谢谢!但是我好想知道我错哪了。
by xinbao324 @ 2024-04-21 11:22:44


|