#3275
Se dau 3 numere naturale, fiecare având câte două cifre. Afișați-le pe acelea care au suma cifrelor maximă.
CNFB - Concurs de pregatire, clasa a 5-a
| Problema | nrSumCifMax | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64321485 | Utilizator | |
| Fișier | nrsumcifmax.cpp | Dimensiune | 326 B |
| Data încărcării | 29 Aprilie 2026, 15:24 | Scor/rezultat | Eroare de compilare |
nrsumcifmax.cpp: In function ‘int main()’: nrsumcifmax.cpp:8:5: error: reference to ‘max’ is ambiguous 8 | max=x%10+x/10; | ^~~ 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 nrsumcifmax.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) | ^~~ nrsumcifmax.cpp:4:11: note: ‘int max’ 4 | int x,y,z,max; | ^~~ nrsumcifmax.cpp:9:18: error: reference to ‘max’ is ambiguous 9 | if(y%10+y/10>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) | ^~~ nrsumcifmax.cpp:4:11: note: ‘int max’ 4 | int x,y,z,max; | ^~~ nrsumcifmax.cpp:10:9: error: reference to ‘max’ is ambiguous 10 | max=y%10+y/10; | ^~~ /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) | ^~~ nrsumcifmax.cpp:4:11: note: ‘int max’ 4 | int x,y,z,max; | ^~~ nrsumcifmax.cpp:11:19: error: reference to ‘max’ is ambiguous 11 | if(z%10+z/10>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) | ^~~ nrsumcifmax.cpp:4:11: note: ‘int max’ 4 | int x,y,z,max; | ^~~ nrsumcifmax.cpp:12:9: error: reference to ‘max’ is ambiguous 12 | max=z%10+z/10; | ^~~ /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) | ^~~ nrsumcifmax.cpp:4:11: note: ‘int max’ 4 | int x,y,z,max; | ^~~ nrsumcifmax.cpp:11:6: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 11 | if(z%10+z/10>max) | ^~ nrsumcifmax.cpp:13:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 13 | cout<<x; | ^~~~ nrsumcifmax.cpp:14:9: error: reference to ‘max’ is ambiguous 14 | if(max==y%10+y/10) | ^~~ /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) | ^~~ nrsumcifmax.cpp:4:11: note: ‘int max’ 4 | int x,y,z,max; | ^~~ nrsumcifmax.cpp:16:9: error: reference to ‘max’ is ambiguous 16 | if(max==z%10+z/10) | ^~~ /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) | ^~~ nrsumcifmax.cpp:4:11: note: ‘int max’ 4 | int x,y,z,max; | ^~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema nrSumCifMax 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ă.