#313
Se dă o matrice cu n linii și n coloane și elemente numere naturale. Calculați diferența în valoare absolută dintre sumele elementelor de pe cele două diagonale.
| Problema | Diagonale | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #62619226 | Utilizator | |
| Fișier | diagonale.cpp | Dimensiune | 327 B |
| Data încărcării | 27 Ianuarie 2026, 19:41 | Scor/rezultat | Eroare de compilare |
diagonale.cpp: In function 'int main()': diagonale.cpp:12:21: warning: capture of variable 'n' with non-automatic storage duration [enabled by default] cin>>a[i][i]>>[n - i + 1]; ^ diagonale.cpp:4:5: note: 'int n' declared here int n,i,j,a[101][101]; ^ diagonale.cpp:12:23: error: expected ',' before '-' token cin>>a[i][i]>>[n - i + 1]; ^ diagonale.cpp:12:23: error: expected identifier before '-' token diagonale.cpp: In lambda function: diagonale.cpp:12:31: error: expected '{' before ';' token cin>>a[i][i]>>[n - i + 1]; ^ diagonale.cpp: In function 'int main()': diagonale.cpp:12:18: error: ambiguous overload for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' and 'main()::__lambda0') cin>>a[i][i]>>[n - i + 1]; ^ diagonale.cpp:12:18: note: candidates are: In file included from /usr/include/c++/4.8/iostream:40:0, from diagonale.cpp:1: /usr/include/c++/4.8/istream:120:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> operator>>(__istream_type& (*__pf)(__istream_type&)) ^ /usr/include/c++/4.8/istream:120:7: note: no known conversion for argument 1 from 'main()::__lambda0' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&) {aka std::basic_istream<char>& (*)(std::basic_istream<char>&)}' /usr/include/c++/4.8/istream:124:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>] <near match> operator>>(__ios_type& (*__pf)(__ios_type&)) ^ /usr/include/c++/4.8/istream:124:7: note: no known conversion for argument 1 from 'main()::__lambda0' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}' /usr/include/c++/4.8/istream:131:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> operator>>(ios_base& (*__pf)(ios_base&)) ^ /usr/include/c++/4.8/istream:131:7: note: no known conversion for argument 1 from 'main()::__lambda0' to 'std::ios_base& (*)(std::ios_base&)' diagonale.cpp:13:9: error: 'd' was not declared in this scope d=a[i][i]; ^ diagonale.cpp:14:9: error: 'd2' was not declared in this scope d2=[n - i + 1]; ^ diagonale.cpp:14:13: warning: capture of variable 'n' with non-automatic storage duration [enabled by default] d2=[n - i + 1]; ^ diagonale.cpp:4:5: note: 'int n' declared here int n,i,j,a[101][101]; ^ diagonale.cpp:14:15: error: expected ',' before '-' token d2=[n - i + 1]; ^ diagonale.cpp:14:15: error: expected identifier before '-' token diagonale.cpp: In lambda function: diagonale.cpp:14:23: error: expected '{' before ';' token d2=[n - i + 1]; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Diagonale 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ă.