Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
111470 | 任斌 | 书的价格 | C++ | Accepted | 1 MS | 268 KB | 702 | 2025-03-02 12:08:51 |
#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<algorithm> #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; struct book{ string name; float price; }b[20]; bool cmp(book x,book y){ return x.price>y.price; } int main(){ int n,i; cin>>n; for(int i=0;i<n;i++){ cin.get(); getline(cin,b[i].name); cin>>b[i].price; } sort(b+0,b+n,cmp); printf("%.2f",b[0].price); cout<<","<<b[0].name<<endl; printf("%.2f",b[n-1].price); cout<<","<<b[n-1].name<<endl; return 0; }
------Input------
3 Programming in C 0 Programming in VB 1 Programming in Delphi 2
------Answer-----
2.00,Programming in Delphi 0.00,Programming in C
------Your output-----