Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
92250 | 刘轻松 | 单价最高的书 | C++ | Accepted | 0 MS | 280 KB | 567 | 2024-09-28 18:10:54 |
#include<iostream> using namespace std; //定义结构体 struct book{ //成员变量 int bh; string sm; int n; int m; //定义成员函数 void iput(){ cin>>bh>>sm>>n>>m; } void output(){ cout<<bh<<' '<<sm<<' '<<n<<' '<<m; } }; //定义结构体数组 book books[100]; int main(){ int N,max=0,k; cin>>N; for(int i=1;i<=N;i++){ books[i].iput(); //调用成员函数 if(books[i].m/books[i].n>max){ max = books[i].m/books[i].n; k = i; } } books[k].output(); cout<<' '<<max; }