Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
94066 | 刘轻松 | 书的价格 | C++ | Accepted | 1 MS | 272 KB | 638 | 2024-10-19 17:57:33 |
#include<bits/stdc++.h> using namespace std; struct book{ string name; double price; }; book bk[11]; int main(){ int n; int max=0,maxid; int min = 10000000,minid; cin>>n; for(int i=1;i<=n;i++){ cin.get(); getline(cin,bk[i].name); cin>>bk[i].price; if(max<bk[i].price){ max = bk[i].price; maxid = i; //记录最大值所在的下标; } if(min>bk[i].price){ min = bk[i].price; minid = i; //记录最小值所在的下标; } } printf("%.2lf,",bk[maxid].price); cout<<bk[maxid].name<<endl; printf("%.2lf,",bk[minid].price); cout<<bk[minid].name<<endl; }