Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
118130 冯诚阳 书的价格 C++ Accepted 1 MS 276 KB 538 2025-04-24 18:27:53

Tests(4/4):


Code:

#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; struct book{ string name; double price; }b[20]; bool cmp(book x,book y){ return x.price>y.price; } int main(){ int i,n; cin>>n; for(i=0;i<n;i++){ cin.get(); getline(cin,b[i].name); cin>>b[i].price; } sort(b+0,b+n,cmp); printf("%.2lf,",b[0].price); cout <<b[0].name<<endl; printf("%.2lf,",b[n-1].price); cout <<b[n-1].name<<endl; return 0; }