Run ID:623
提交时间:2022-12-23 21:04:42
#include<iostream> #include<algorithm> using namespace std; struct book { float price; char name[30]; }; bool cmp(book x,book y) { return x<y; } 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,cmp); printf("%.2lf ",a[n-1].price); cout<<a[n-1].name<<endl; printf("%.2lf ",a[0].price); cout<<a[0].name<<endl; return 0; }