Run ID:36633

提交时间:2022-08-10 16:10:25

#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; struct book{ string name; double price; }b[25]; bool cmp(book x,book y){ return x.price>y.price; } int main(){ int n,i; cin>>n; for(i=0;i<n;i++){ getchar(); getline(cin,b[i].name); cin>>b[i].price; } sort(b+0,b+n,cmp); printf("%.2lf,",b[0].price); cout<<b[0].name<<endl; printf("%.2lf,",b[n-1].price); cout<<b[n-1].name<<endl; return 0; }