Run ID:89

提交时间:2022-07-19 09:41:33

#include<iostream> #include<algorithm> using namespace std; struct book { float price; char name[30]; }; bool cm(book x,book y) { return x.price<y.price; } int main() { int n; cin>>n; struct book a[n]; for(int i=0;i<n;i++) { cin>>a[i].name>>a[i].price; } sort(a,a+n,cm); printf("%.2lf ",a[n-1].price); cout<<a[n-1].name<<endl; printf("%.2lf ",a[0].price); cout<<a[0].name<<endl; return 0; }