Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
623 | 关清声 | 书的价格 | C++ | Compile Error | 0 MS | 0 KB | 475 | 2022-12-23 21:04:42 |
#include<iostream> #include<algorithm> using namespace std; struct book { float price; char name[30]; }; bool cmp(book x,book y) { return x<y; } int main() { int n; cin>>n; struct book a[n]; for(int i=0;i<n;i++) { cin>>a[i].name>>a[i].price; } sort(a,a+n,cmp); printf("%.2lf ",a[n-1].price); cout<<a[n-1].name<<endl; printf("%.2lf ",a[0].price); cout<<a[0].name<<endl; return 0; }
Main.cc: In function 'bool cmp(book, book)': Main.cc:11:13: error: no match for 'operator<' (operand types are 'book' and 'book') return x constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^ /usr/include/c++/4.8.2/bits/stl_pair.h:220:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::pair<_T1, _T2>' return x bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator<(const reverse_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8.2/bits/stl_iterator.h:297:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::reverse_iterator<_Iterator>' return x bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator<(const reverse_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8.2/bits/stl_iterator.h:347:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::reverse_iterator<_Iterator>' return x bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&) operator<(const move_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8.2/bits/stl_iterator.h:1055:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::move_iterator<_Iterator>' return x bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&) operator<(const move_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8.2/bits/stl_iterator.h:1061:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::move_iterator<_Iterator>' return x bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&) operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8.2/bits/basic_string.h:2569:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' return x bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8.2/bits/basic_string.h:2581:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' return x bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&) operator<(const _CharT* __lhs, ^ /usr/include/c++/4.8.2/bits/basic_string.h:2593:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: mismatched types 'const _CharT*' and 'book' return x bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) ^ /usr/include/c++/4.8.2/bits/stl_vector.h:1421:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::vector<_Tp, _Alloc>' return x bool std::operator<(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&) operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) ^ /usr/include/c++/4.8.2/array:238:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::array<_Tp, _Nm>' return x constexpr bool std::operator<(const std::tuple<_Elements ...>&, const std::tuple<_Elements ...>&) operator<(const tuple<_TElements...>& __t, ^ /usr/include/c++/4.8.2/tuple:824:5: note: template argument deduction/substitution failed: Main.cc:11:14: note: 'book' is not derived from 'const std::tuple<_Elements ...>' return x<y; ^ Main.cc:12:1: warning: control reaches end of non-void function [-Wreturn-type] } ^