#225
Scrieţi un program care citeşte de la tastatură doua numere naturale n şi k şi construieşte în memorie o matrice cu n linii şi n coloane formată numai din valori 1, 2, 3 şi 4 astfel încât: elementele aflate la intersecţia primelor k linii cu primele k coloane sunt egale cu 1, elementele aflate la intersecţia primelor k linii cu ultimele n-k coloane sunt egale cu 2, elementele aflate la intersecţia ultimelor n-k linii cu primele k coloane sunt egale cu 3, elementele aflate la intersecţia ultimelor n-k linii cu ultimele n-k coloane sunt egale cu 4.
Variante Bacalaureat 2009
| Problema | GenMat12 | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64770313 | Utilizator | |
| Fișier | genmat12.cpp | Dimensiune | 590 B |
| Data încărcării | 29 Mai 2026, 08:20 | Scor/rezultat | Eroare de compilare |
genmat12.cpp: In function ‘int main()’: genmat12.cpp:5:17: error: expected initializer before ‘a’ 5 | int n,k,i,j a[25][25]; | ^ genmat12.cpp:8:13: error: ‘j’ was not declared in this scope 8 | for(j=1;j<=k;j++) | ^ genmat12.cpp:9:9: error: ‘a’ was not declared in this scope 9 | a[i][j]=1; | ^ genmat12.cpp:7:5: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 7 | for(i=1;i<=k;i++) | ^~~ genmat12.cpp:11:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 11 | for(i=1;i<=k;i++) | ^~~ genmat12.cpp:12:13: error: ‘j’ was not declared in this scope 12 | for(j=k+1;j<=n;j++) | ^ genmat12.cpp:13:9: error: ‘a’ was not declared in this scope 13 | a[i][j]=2; | ^ genmat12.cpp:16:13: error: ‘j’ was not declared in this scope 16 | for(j=1;j<=k;j++) | ^ genmat12.cpp:17:9: error: ‘a’ was not declared in this scope 17 | a[i][j]=3; | ^ genmat12.cpp:20:13: error: ‘j’ was not declared in this scope 20 | for(j=k+1;j<=n;j++) | ^ genmat12.cpp:21:9: error: ‘a’ was not declared in this scope 21 | a[i][j]=4; | ^ genmat12.cpp:25:13: error: ‘j’ was not declared in this scope 25 | for(j=1;j<=n;j++) | ^ genmat12.cpp:26:19: error: ‘a’ was not declared in this scope 26 | cout<<a[i][j]<<" "; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema GenMat12 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ă.