#3530
oop_2
C++
Scrieți definiția completă a metodelor Max
și Cauta
. Funcția Max
trebuie să returneze valoarea maximă din vectorul t
. Funcția Cauta(val)
caută valoarea val
în vectorul t
și fie trebuie să returneze cea mai din stânga poziție unde se află valoarea val
, fie să returneze -1
dacă val
nu se află în t
.
Folclorul informatic
Problema | oop_2 | Operații I/O |
oop_2.in /oop_2.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #37522621 | Utilizator | |
Fișier | oop_2.cpp | Dimensiune | 306 B |
Data încărcării | 08 Septembrie 2022, 00:13 | Scor / rezultat | Eroare de compilare |
oop_2.cpp:57:1: error: expected '}' at end of input } ^ oop_2.cpp: In member function 'int Tablou::Max()': oop_2.cpp:27:15: error: no matching function for call to 'begin(int*&)' for(auto max1:t) ^ oop_2.cpp:27:15: note: candidates are: In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94:0, from oop_2.cpp:1: /usr/include/c++/4.8/valarray:1206:5: note: template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&) begin(const valarray<_Tp>& __va) ^ /usr/include/c++/4.8/valarray:1206:5: note: template argument deduction/substitution failed: oop_2.cpp:27:15: note: mismatched types 'const std::valarray<_Tp>' and 'int*' for(auto max1:t) ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94:0, from oop_2.cpp:1: /usr/include/c++/4.8/valarray:1196:5: note: template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&) begin(valarray<_Tp>& __va) ^ /usr/include/c++/4.8/valarray:1196:5: note: template argument deduction/substitution failed: oop_2.cpp:27:15: note: mismatched types 'std::valarray<_Tp>' and 'int*' for(auto max1:t) ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:42:0, from /usr/include/c++/4.8/string:52, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from oop_2.cpp:1: /usr/include/c++/4.8/initializer_list:89:5: note: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>) begin(initializer_list<_Tp> __ils) noexcept ^ /usr/include/c++/4.8/initializer_list:89:5: note: template argument deduction/substitution failed: oop_2.cpp:27:15: note: mismatched types 'std::initializer_list<_Tp>' and 'int*' for(auto max1:t) ^ In file included from /usr/include/c++/4.8/string:51:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from oop_2.cpp:1: /usr/include/c++/4.8/bits/range_access.h:87:5: note: template<class _Tp, unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm]) begin(_Tp (&__arr)[_Nm]) ^ /usr/include/c++/4.8/bits/range_access.h:87:5: note: template argument deduction/substitution failed: oop_2.cpp:27:15: note: mismatched types '_Tp [_Nm]' and 'int*' for(auto max1:t) ^ In file included from /usr/include/c++/4.8/string:51:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from oop_2.cpp:1: /usr/include/c++/4.8/bits/range_access.h:58:5: note: template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) begin(const _Container& __cont) -> decltype(__cont.begin()) ^ /usr/include/c++/4.8/bits/range_access.h:58:5: note: template argument deduction/substitution failed: /usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) [with _Container = int*]': oop_2.cpp:27:15: required from here /usr/include/c++/4.8/bits/range_access.h:58:5: error: request for member 'begin' in '__cont', which is of non-class type 'int* const' /usr/include/c++/4.8/bits/range_access.h:48:5: note: template<class _Container> decltype (__cont.begin()) std::begin(_Container&) begin(_Container& __cont) -> decltype(__cont.begin()) ^ /usr/include/c++/4.8/bits/range_access.h:48:5: note: template argument deduction/substitution failed: /usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container = int*]': oop_2.cpp:27:15: required from here /usr/include/c++/4.8/bits/range_access.h:48:5: error: request for member 'begin' in '__cont', which is of non-class type 'int*' oop_2.cpp:27:15: error: no matching function for call to 'end(int*&)' for(auto max1:t) ^ oop_2.cpp:27:15: note: candidates are: In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94:0, from oop_2.cpp:1: /usr/include/c++/4.8/valarray:1226:5: note: template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&) end(const valarray<_Tp>& __va) ^ /usr/include/c++/4.8/valarray:1226:5: note: template argument deduction/substitution failed: oop_2.cpp:27:15: note: mismatched types 'const std::valarray<_Tp>' and 'int*' for(auto max1:t) ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94:0, from oop_2.cpp:1: /usr/include/c++/4.8/valarray:1216:5: note: template<class _Tp> _Tp* std::end(std::valarray<_Tp>&) end(valarray<_Tp>& __va) ^ /usr/include/c++/4.8/valarray:1216:5: note: template argument deduction/substitution failed: oop_2.cpp:27:15: note: mismatched types 'std::valarray<_Tp>' and 'int*' for(auto max1:t) ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:42:0, from /usr/include/c++/4.8/string:52, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from oop_2.cpp:1: /usr/include/c++/4.8/initializer_list:99:5: note: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>) end(initializer_list<_Tp> __ils) noexcept ^ /usr/include/c++/4.8/initializer_list:99:5: note: template argument deduction/substitution failed: oop_2.cpp:27:15: note: mismatched types 'std::initializer_list<_Tp>' and 'int*' for(auto max1:t) ^ In file included from /usr/include/c++/4.8/string:51:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from oop_2.cpp:1: /usr/include/c++/4.8/bits/range_access.h:97:5: note: template<class _Tp, unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm]) end(_Tp (&__arr)[_Nm]) ^ /usr/include/c++/4.8/bits/range_access.h:97:5: note: template argument deduction/substitution failed: oop_2.cpp:27:15: note: mismatched types '_Tp [_Nm]' and 'int*' for(auto max1:t) ^ In file included from /usr/include/c++/4.8/string:51:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from oop_2.cpp:1: /usr/include/c++/4.8/bits/range_access.h:78:5: note: template<class _Container> decltype (__cont.end()) std::end(const _Container&) end(const _Container& __cont) -> decltype(__cont.end()) ^ /usr/include/c++/4.8/bits/range_access.h:78:5: note: template argument deduction/substitution failed: /usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(const _Container&) [with _Container = int*]': oop_2.cpp:27:15: required from here /usr/include/c++/4.8/bits/range_access.h:78:5: error: request for member 'end' in '__cont', which is of non-class type 'int* const' /usr/include/c++/4.8/bits/range_access.h:68:5: note: template<class _Container> decltype (__cont.end()) std::end(_Container&) end(_Container& __cont) -> decltype(__cont.end()) ^ /usr/include/c++/4.8/bits/range_access.h:68:5: note: template argument deduction/substitution failed: /usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(_Container&) [with _Container = int*]': oop_2.cpp:27:15: required from here /usr/include/c++/4.8/bits/range_access.h:68:5: error: request for member 'end' in '__cont', which is of non-class type 'int*' oop_2.cpp: In member function 'int Tablou::Cauta(int)': oop_2.cpp:38:18: error: request for member 'size' in '((Tablou*)this)->Tablou::t', which is of non-class type 'int*' for(int a=0; a<t.size(); a++){ ^ oop_2.cpp:46:1: error: a function-definition is not allowed here before '{' token { ^ oop_2.cpp:57:1: error: expected '}' at end of input } ^ oop_2.cpp: At global scope: oop_2.cpp:57:1: error: expected unqualified-id at end of input
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema oop_2 face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.