Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
624 关清声 书的价格 C++ Accepted 0 MS 268 KB 562 2022-12-23 21:04:56

Tests(4/4):


Code:

#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<<endl; return 0; }