Run ID:94

提交时间:2022-07-19 09:47:40

#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> using namespace std; struct book { float price; string name; }; 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++) { getchar(); getline(cin,a[i].name); cin>>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; return 0; }