Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
65797 蔚佳良 书的价格 C++ Compile Error 0 MS 0 KB 545 2024-02-19 16:30:45

Tests(0/0):


Code:

#include<iostream> #include<cstring> #include<algorithm> struct stu{ string name; double price; }a[310]; bool cmp(stu x,stu y){ if(x.price!=y.price) return x.price>y.price; else return x.name<y.name; } int main(){ int n; cin>>n; for(int i=0;i<n;i++) cin>>a[i].name>>a[i].price; sort(a,a+n,cmp); printf("%.2lf",a[n].price); cout<<','<<a[n].name<<endl; printf("%.2lf",a[n-1].price); cout<<','<<a[n-1].name<<endl; return 0; }


Run Info:

Main.cc:5:4: error: 'string' does not name a type
    string name; 
    ^
Main.cc: In function 'bool cmp(stu, stu)':
Main.cc:12:17: error: 'struct stu' has no member named 'name'
        return x.name>n; 
    ^
Main.cc:16:4: note: suggested alternative:
In file included from Main.cc:1:0:
/usr/include/c++/5/iostream:60:18: note:   'std::cin'
   extern istream cin;  /// Linked to standard input
                  ^
Main.cc:18:18: error: 'struct stu' has no member named 'name'
        cin>>a[i].name>>a[i].price; 
                  ^
Main.cc:19:18: error: 'sort' was not declared in this scope
    sort(a,a+n,cmp); 
                  ^
Main.cc:19:18: note: suggested alternative:
In file included from /usr/include/c++/5/algorithm:62:0,
                 from Main.cc:3:
/usr/include/c++/5/bits/stl_algo.h:4718:5: note:   'std::sort'
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^
Main.cc:21:4: error: 'cout' was not declared in this scope
    cout<<','<& __os)
     ^
Main.cc:23:22: error: 'struct stu' has no member named 'name'
    cout<<','<