#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 | #59663192 | Utilizator | |
| Fișier | genmat12.cpp | Dimensiune | 541 B |
| Data încărcării | 06 Octombrie 2025, 14:01 | Scor/rezultat | Eroare de compilare |
genmat12.cpp: In function 'int main()': genmat12.cpp:9:18: warning: left operand of comma operator has no effect [-Wunused-value] for(int i=1;i<=k,i++) ^ genmat12.cpp:9:25: error: expected ';' before ')' token for(int i=1;i<=k,i++) ^ genmat12.cpp:13:21: error: expected initializer before '<=' token for(int j=k+1,j<=n;j ^ genmat12.cpp:13:21: error: expected ';' before '<=' token genmat12.cpp:13:21: error: expected primary-expression before '<=' token genmat12.cpp:13:25: warning: for increment expression has no effect [-Wunused-value] for(int j=k+1,j<=n;j ^ genmat12.cpp:14:5: error: expected ')' before 'a' a[i][j]=2 ^ genmat12.cpp:15:6: error: expected ';' before 'for' for(int i=1;i<=k;i++) ^ genmat12.cpp:15:19: warning: statement has no effect [-Wunused-value] for(int i=1;i<=k;i++) ^ genmat12.cpp:15:26: error: expected ';' before ')' token for(int i=1;i<=k;i++) ^ genmat12.cpp:17:5: error: expected ';' before 'a' a[i][j]=3 ^ genmat12.cpp:18:18: warning: statement has no effect [-Wunused-value] for(int i=k+1;i<=n;++i) ^ genmat12.cpp:18:20: warning: statement has no effect [-Wunused-value] for(int i=k+1;i<=n;++i) ^ genmat12.cpp:18:27: error: expected ';' before ')' token for(int i=k+1;i<=n;++i) ^ genmat12.cpp:19:24: warning: left operand of comma operator has no effect [-Wunused-value] for(int j=k+1;j<=n,j++) ^ genmat12.cpp:19:31: error: expected ';' before ')' token for(int j=k+1;j<=n,j++) ^ genmat12.cpp:21:22: warning: left operand of comma operator has no effect [-Wunused-value] for(int i=1;i<=n,i++) ^ genmat12.cpp:21:29: error: expected ';' before ')' token for(int i=1;i<=n,i++) ^ genmat12.cpp:22:22: warning: statement has no effect [-Wunused-value] for(int j=1;j<=n;j++ ^ genmat12.cpp:23:5: error: expected ';' before '{' token { 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ă.