#4694
Un joc folosește o tablă dreptunghiulară, pe care sunt reprezentate celule de dimensiune egală, dispuse pe m
linii și pe n
coloane. În fiecare celulă este înscris un număr natural.
Numim pătrat de valoare p
patru celule ale tablei, situate pe două linii consecutive și pe două coloane consecutive, cu proprietatea că suma valorilor înscrise în aceste celule este egală cu p
. Scopul jocului este determinarea unui pătrat de valoare maximă.
Scrieți un program C/C++ care citește de la tastatură două numere naturale din intervalul [2,20]
, m
și n
, apoi elementele unui tablou bidimensional cu m
linii și n
coloane, numere naturale din intervalul [0,10000]
, reprezentând numerele înscrise pe tabla de joc, în ordinea dispunerii celulelor corespunzătoare. Programul determină un pătrat de valoare maximă al tablei și afișează pe ecran această valoare.
Bacalaureat 2023 sesiunea august
Problema | bac_patrat | Operații I/O |
![]() |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #58344008 | Utilizator | |
Fișier | bac_patrat.cpp | Dimensiune | 366 B |
Data încărcării | 28 Mai 2025, 12:29 | Scor / rezultat | Eroare de compilare |
bac_patrat.cpp: In lambda function: bac_patrat.cpp:13:42: error: expected '{' before '+' token int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ bac_patrat.cpp: In function 'int main()': bac_patrat.cpp:13:38: error: no match for 'operator+' (operand types are 'int*' and 'main()::__lambda0') int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ bac_patrat.cpp:13:38: note: candidates are: In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:333:5: note: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&) operator+(typename reverse_iterator<_Iterator>::difference_type __n, ^ /usr/include/c++/4.8/bits/stl_iterator.h:333:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: 'main()::__lambda0' is not derived from 'const std::reverse_iterator<_Iterator>' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1118:5: note: template<class _Iterator> std::move_iterator<_Iterator> std::operator+(typename std::move_iterator<_Iterator>::difference_type, const std::move_iterator<_Iterator>&) operator+(typename move_iterator<_Iterator>::difference_type __n, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1118:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: 'main()::__lambda0' is not derived from 'const std::move_iterator<_Iterator>' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2365:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> 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/bits/basic_string.h:2365:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'int*' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:53: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.tcc:692:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&) operator+(const _CharT* __lhs, ^ /usr/include/c++/4.8/bits/basic_string.tcc:692:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: 'main()::__lambda0' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:53: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.tcc:708:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::basic_string<_CharT, _Traits, _Alloc>&) operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) ^ /usr/include/c++/4.8/bits/basic_string.tcc:708:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: 'main()::__lambda0' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2402:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2402:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'int*' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2418:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, _CharT) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) ^ /usr/include/c++/4.8/bits/basic_string.h:2418:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'int*' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2430:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const std::basic_string<_CharT, _Traits, _Alloc>&) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2430:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: mismatched types 'std::basic_string<_CharT, _Traits, _Alloc>' and 'int*' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2436:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>&&) operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2436:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: mismatched types 'const std::basic_string<_CharT, _Traits, _Alloc>' and 'int*' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2442:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, std::basic_string<_CharT, _Traits, _Alloc>&&) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2442:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: mismatched types 'std::basic_string<_CharT, _Traits, _Alloc>' and 'int*' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2454:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>&&) operator+(const _CharT* __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2454:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: 'main()::__lambda0' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2460:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::basic_string<_CharT, _Traits, _Alloc>&&) operator+(_CharT __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2460:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: 'main()::__lambda0' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2466:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2466:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: mismatched types 'std::basic_string<_CharT, _Traits, _Alloc>' and 'int*' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ In file included from /usr/include/c++/4.8/string:52: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/ostream:38, from /usr/include/c++/4.8/iostream:39, from bac_patrat.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2472:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, _CharT) operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2472:5: note: template argument deduction/substitution failed: bac_patrat.cpp:13:42: note: mismatched types 'std::basic_string<_CharT, _Traits, _Alloc>' and 'int*' int S=a[i][j]+a[i][j+1]+a[i+1]+[j]+a[i+1][j+1]; ^ bac_patrat.cpp:14:11: error: 's' was not declared in this scope if(s>maxi) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema bac_patrat 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ă.