我来救人啦!!!(结构体,c++)

LS_shenkeyi 2023-12-09 21:01:56 2023-12-09 21:02:17 5 返回题目

#include <bits/stdc++.h> using namespace std; struct node { int x; double y; string z; }; node q[10005]; int n; int main() { scanf("%d",&n); for(int i=1; i<=n; i++) cin>>q[i].x>>q[i].y>>q[i].z; for(int i=1; i<n; i++) for(int j=i+1; j<=n; j++) if(q[j].x<q[i].x) swap(q[j].x,q[i].x),swap(q[j].y,q[i].y),swap(q[j].z,q[i].z); for(int i=1; i<=n; i++) {

cout<<q[i].x<<" ";
cout<<fixed<<setprecision(2)<<q[i].y<<" ";
cout<<q[i].z<<endl;

}

return 0; }

{{ vote && vote.total.up }}