#4925
Se dă numărul natural n și un șir de n * (n - 1) / 2 numere naturale. Să se construiască o matrice cu n linii și n coloane în care cele n * (n - 1) / 2 numere se pun deasupra diagonalei principale astfel: primele n-1 numere se pun pe prima linie, de la coloana 2 la coloana n, următoarele n-2 numere din șir se pun pe linia 2, de la coloanele 3 la n, șa.m.d. Apoi valorile de deasupra diagonalei principale se pun simetric și sub diagonala principală. Elementele diagonalei principale rămân nule.
| Problema | CompletareMatrice | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #62327128 | Utilizator | |
| Fișier | completarematrice.cpp | Dimensiune | 459 B |
| Data încărcării | 17 Ianuarie 2026, 20:46 | Scor/rezultat | Eroare de compilare |
completarematrice.cpp: In function 'int main()': completarematrice.cpp:4:11: error: declaration of 'v' as multidimensional array must have bounds for all dimensions except the first int n,v[][],i,j,contor=1; ^ completarematrice.cpp:6:1: error: 'val' was not declared in this scope val=n*(n-1)/2 ^ completarematrice.cpp:7:1: error: expected ';' before 'int' int sir[val]; ^ completarematrice.cpp:9:19: error: 'sir' was not declared in this scope {cout<<"n= ";cin>>sir[i];} ^ completarematrice.cpp:12:13: error: 'v' was not declared in this scope if(i<j){v[i][j]=sir[contor]; ^ completarematrice.cpp:12:21: error: 'sir' was not declared in this scope if(i<j){v[i][j]=sir[contor]; ^ completarematrice.cpp:13:21: error: expected ';' before '}' token contor++}; ^ completarematrice.cpp:14:11: warning: suggest parentheses around assignment used as truth value [-Wparentheses] if(i=j)v[i][j]=0; ^ completarematrice.cpp:14:12: error: 'v' was not declared in this scope if(i=j)v[i][j]=0; ^ completarematrice.cpp:15:13: error: 'v' was not declared in this scope if(j<i){v[i][j]={sir[contor]; ^ completarematrice.cpp:15:22: error: 'sir' was not declared in this scope if(j<i){v[i][j]={sir[contor]; ^ completarematrice.cpp:15:33: error: expected '}' before ';' token if(j<i){v[i][j]={sir[contor]; ^ completarematrice.cpp:16:30: error: expected ';' before '}' token contor--}}; ^ completarematrice.cpp:19:11: error: 'v' was not declared in this scope cout<<v[i][j]<<" "; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema CompletareMatrice 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ă.