Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
117773 | 石水生 | 书的价格 | C++ | Accepted | 1 MS | 276 KB | 434 | 2025-04-20 12:06:46 |
#include <bits/stdc++.h> using namespace std; struct book{ string name; double money; }; bool cmp(book a,book b){ return a.money>b.money; } struct book a[10]; int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin.get(); getline(cin,a[i].name); cin>>a[i].money; } sort(a+0,a+n,cmp); printf("%.2lf,",a[0].money); cout<<a[0].name<<endl; printf("%.2lf,",a[n-1].money); cout<<a[n-1].name<<endl; }