提交时间:2025-05-03 15:13:44
运行 ID: 320103
#include <bits/stdc++.h> using namespace std; struct hsg{ string s; double h; }a[45]; bool cmp(hsg x,hsg y){ if(x.s!=y.s) return x.s>y.s; if(x.s=="male") return x.h<y.h; return x.h>y.h; } int main() { int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].s>>a[i].h; } sort(a+1,a+n+1,cmp); for(int i=1;i<=n;i++){ cout<<fixed<<setprecision(2)<<a[i].h<<" "; } return 0; }