Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
3245 邓小龙 单价最高的书 C++ Accepted 0 MS 260 KB 617 2024-04-26 20:12:33

Tests(2/2):


Code:

# include<iostream> using namespace std; struct Book{ int id; string name; int qty; int price_tot; //int unit_price; //unit_price=price_tot/qty; }; int n; Book book[101]; int main(){ cin>>n; struct Book maxn; maxn.price_tot=0; maxn.qty=1; for(int i=1;i<=n;i++){ cin>>book[i].id>>book[i].name>>book[i].qty>>book[i].price_tot; if(maxn.price_tot/maxn.qty<book[i].price_tot/book[i].qty) maxn=book[i]; } cout<<maxn.id<<" "<<maxn.name<<" "<<maxn.qty<<" "<<maxn.price_tot<<" "<<maxn.price_tot/maxn.qty<<endl; return 0; }