#346
Să se scrie un program care citește un șir de n numere naturale şi determină valoarea maximă din șir și de câte ori apare.
| Problema | MaxAndAp | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64753956 | Utilizator | |
| Fișier | maxandap.cpp | Dimensiune | 315 B |
| Data încărcării | 27 Mai 2026, 23:11 | Scor/rezultat | Eroare de compilare |
maxandap.cpp: In function ‘int main()’: maxandap.cpp:9:5: error: reference to ‘max’ is ambiguous 9 | max=v[0]; | ^~~ In file included from /usr/include/c++/13/string:51, from /usr/include/c++/13/bits/locale_classes.h:40, from /usr/include/c++/13/bits/ios_base.h:41, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/ostream:40, from /usr/include/c++/13/iostream:41, from maxandap.cpp:1: /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ maxandap.cpp:3:18: note: ‘long int max’ 3 | long int n,i,k=0,max,v[1000]; | ^~~ maxandap.cpp:11:12: error: reference to ‘max’ is ambiguous 11 | if(max<v[i]) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ maxandap.cpp:3:18: note: ‘long int max’ 3 | long int n,i,k=0,max,v[1000]; | ^~~ maxandap.cpp:12:13: error: reference to ‘max’ is ambiguous 12 | max=v[i]; | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ maxandap.cpp:3:18: note: ‘long int max’ 3 | long int n,i,k=0,max,v[1000]; | ^~~ maxandap.cpp:14:18: error: reference to ‘max’ is ambiguous 14 | if(v[i]==max) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ maxandap.cpp:3:18: note: ‘long int max’ 3 | long int n,i,k=0,max,v[1000]; | ^~~ maxandap.cpp:16:11: error: reference to ‘max’ is ambiguous 16 | cout<<max<<" "<<k; | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidates are: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: ‘template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ maxandap.cpp:3:18: note: ‘long int max’ 3 | long int n,i,k=0,max,v[1000]; | ^~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema MaxAndAp face parte din prima categorie. 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ă.