Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
441 | 关清声 | 书的价格 | C++ | Accepted | 0 MS | 272 KB | 566 | 2022-08-19 15:46:22 |
#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; }