#3072
Scrieți un program care citește un număr natural nenul n și care determină și afișează trei numere naturale a, b și c, astfel încât a+b+c=n și produsul a*b*c este maximul dintre produsele oricăror trei numere naturale care adunate dau suma egală cu n.
| Problema | sumprodmax3 | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64650464 | Utilizator | |
| Fișier | sumprodmax3.cpp | Dimensiune | 172 B |
| Data încărcării | 20 Mai 2026, 13:47 | Scor/rezultat | Eroare de compilare |
sumprodmax3.cpp: In function ‘int main()’: sumprodmax3.cpp:10:11: error: no match for ‘operator-’ (operand type is ‘std::ostream’ {aka ‘std::basic_ostream<char>’}) 10 | c=n-b;- | ^ 11 | cout<<a<<' '<<b<<' '<<c; | ~~~~ sumprodmax3.cpp:10:11: note: candidate: ‘operator-(int)’ (built-in) sumprodmax3.cpp:10:11: note: no known conversion for argument 1 from ‘std::ostream’ {aka ‘std::basic_ostream<char>’} to ‘int’ In file included from /usr/include/c++/13/string:48, 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 sumprodmax3.cpp:1: /usr/include/c++/13/bits/stl_iterator.h:625:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’ 625 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:625:5: note: template argument deduction/substitution failed: sumprodmax3.cpp:11:5: note: ‘std::ostream’ {aka ‘std::basic_ostream<char>’} is not derived from ‘const std::reverse_iterator<_Iterator>’ 11 | cout<<a<<' '<<b<<' '<<c; | ^~~~ /usr/include/c++/13/bits/stl_iterator.h:1800:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’ 1800 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1800:5: note: template argument deduction/substitution failed: sumprodmax3.cpp:11:5: note: ‘std::ostream’ {aka ‘std::basic_ostream<char>’} is not derived from ‘const std::move_iterator<_IteratorL>’ 11 | cout<<a<<' '<<b<<' '<<c; | ^~~~ sumprodmax3.cpp: At global scope: sumprodmax3.cpp:12:2: error: expected unqualified-id before ‘-’ token 12 | }- | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema sumprodmax3 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ă.