Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
61041 万正钰 书的价格 C++ Compile Error 0 MS 0 KB 555 2023-11-25 17:39:14

Tests(0/0):


Code:

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


Run Info:

Main.cc: In function 'int main()':
Main.cc:21:18: error: 'struct m' has no member named 'price'
         cin>a[i].price;
                  ^