Matrici


 * Probleme matrici**

Proiect joc SUS-JOS

Probleme din variantele de BAC

Matrici nxm

1. Se citesc numarul de linii (n) si numarul de coloane (m) ale unei matrici. a) sa se citeasca matricea b) sa se afiseze matricea c) sa se determine suma valorilor matricii d) sa se determine elementul maxim din matrice e) sa se afiseze elementele liniei t f) sa se afiseze elementele coloanei k g)sa se afiseze numerele pare de pe linia l h)sa se afiseze elementul minim din matrice i) sa se afiseze suma elementelor fiecarei linii j)sa se afiseze produsul elementelor fiecarei coloane k)sa se verifice daca primele 2 linii din matrice sunt identice l)sa se ordoneze crescator prima coloana m)sa se ordoneze descrescator ultima coloana n)sa se afiseze, sub forma de matrice, doar ultima cifra a fiecarui element o)sa se afiseze pe o singura linie elementele matricii parcurse pe coloane p)copiati intr-un vector elementele de pe rama matricii. Ordonati descrescator vectorul

2. Se citesc numarul de linii (n) si numarul de coloane (m) ale unei matrici. a) sa se citeasca matricea b) sa se interschimbe linia l1 cu linia l2 c) sa se ordoneze crescator linia l1 d) sa se afiseze rama matricii e) ordonati descrescator coloana c1 f) afisati suma elementelor de pe ultima coloana


 * Zone speciale in matrice**
 * o mica teorie gasiti aici:[[file:teorie_matrice.pdf]]**

3.Se citeste o matrice patratica. (n linii n coloane) a) afisati diagonala principala (cu o singura str. repetitiva) b) afisati diagonala secundara (cu o singura str. repetitiva) c) afisati suma elementelor de deasupra diagonalei principale d) afisati elementele prime din zona N e) afisati elementele palindroame din zona S f) afisati elementele din zona E si numarul lor de divizori g)afisati elementul maxim/minim din zona V

4. Se citeste o matrice patratica. (n linii n coloane) a) ordonati crescator diagonala principala b) ordonati descrescator diagonala secundara c) interschimbati elem.diagonalei principale cu cele ale diagonalei secundare

5.Se citeste o matrice patratica. (n linii n coloane) a) calculati suma elementelor fiecarei linii si memorati-o pe coloana n+1 b) calculati produsul elementelor fiecarei coloane si memorati-l pe linia n+1. c) completati elementul a[n+1][n+1] cu valoarea 0 d) afisati noua matrice Ex: 1 2 3 4 5 6 7 8 9 devine

1 2 3 6 4 5 6 15 7 8 9 24 12 15 18 0

 6. Fie o matrice patratica cu numere intregi. a) Determinati numarul de valori negative care se gasesc sub diagonala principala. b) Determinati media aritmetica a valorilor pozitive care se gasesc deasupra diagonalei secundare. c) Eliminati din matrice linia si coloana pe care se afla valoarea minima a matricei (este unica).

7. Se citeste o matice cu n linii si m coloane numere intregi. <span style="font-family: Arial,Helvetica,sans-serif;">a) Afisati cate numere pozitive contine fiecare linie. <span style="font-family: Arial,Helvetica,sans-serif;">a1)Afisati indicii liniilor pe care suma este maxima <span style="font-family: Arial,Helvetica,sans-serif;">b) Afisati elementele matricei parcurgand matricea ca un sarpe pe linii. <span style="font-family: Arial,Helvetica,sans-serif;">c) Afisati elementele matricei parcurgand matricea ca un sarpe pe coloane. <span style="font-family: Arial,Helvetica,sans-serif;">d) Generati un vector care sa contina toate numerele pozitive din matrice. <span style="font-family: Arial,Helvetica,sans-serif;">e) Eliminati din matrice linia k (0<=k<n).

<span style="font-family: Arial,Helvetica,sans-serif;">8. Se considera o matrice patratica, cu n linii si coloane, avand elemente numere naturale. <span style="font-family: Arial,Helvetica,sans-serif;">a. Schimbati intre ele liniile matricei astfel incat prima coloana fie ordonata crescator; <span style="font-family: Arial,Helvetica,sans-serif;">b. Calculati suma elementelor unei matrice pătratice de pe diagonala secundară.

<span style="font-family: Arial,Helvetica,sans-serif;">9. Fie o matrice cu numere intregi. <span style="font-family: Arial,Helvetica,sans-serif;">a) Afisati liniile in care valorile sunt in ordine crescatoare <span style="font-family: Arial,Helvetica,sans-serif;">b) Determinati valorile maxim local, si indicii unde se gasesc acestea. O valoare este maxim local daca este mai mare sau egala decat oricare din cei 8 vecini ai sai. <span style="font-family: Arial,Helvetica,sans-serif;">c) Schimbati intre ele coloanele egal departate de margini. <span style="font-family: Arial,Helvetica,sans-serif;">d) Adaugati o coloana cu sumele valorilor de pe fiecare linie si apoi adaugati o linie cu sumele valorilor de pe fiecare coloana.

<span style="font-family: Arial,Helvetica,sans-serif;">10. Fie o matrice patratica cu valori naturale. <span style="font-family: Arial,Helvetica,sans-serif;">a) Schimbati valorile de pe diagonala principala astfel incat sa fie in ordine inversa. <span style="font-family: Arial,Helvetica,sans-serif;">b) Construiti un vector cu numerele de pe rama matricei (prima si ultima linie si coloana) parcursa in sensul acelor de ceasornic pornind de la primul element de pe prima linie si afisati vectorul obtinut. <span style="font-family: Arial,Helvetica,sans-serif;">c) Verificati daca matricea este triunghiulara superior (are toate valorile de sub diagonala principala nule). <span style="font-family: Arial,Helvetica,sans-serif;">d) Verificati daca pe fiecare linie se gasesc primele n numere naturale. <span style="font-family: Arial,Helvetica,sans-serif;">e) Afisati valorile parcurgand matricea in spirala

<span style="font-family: Arial,Helvetica,sans-serif;">11. Se citeste o matrice care contine doar valori de 0 si 1. <span style="font-family: Arial,Helvetica,sans-serif;">a) Afisati linia/liniile care contine cele mai multe valori egale cu 1(unu). <span style="font-family: Arial,Helvetica,sans-serif;">b) Afisati linia care este reprezentarea binara a numarul maxim si valoarea maxima.

<span style="font-family: Arial,Helvetica,sans-serif;">12. Fie o matrice cu numere intregi. <span style="font-family: Arial,Helvetica,sans-serif;"> a) Afisati fiecare coloana a matricei pe cate o linie incepand cu ultima. <span style="font-family: Arial,Helvetica,sans-serif;"> b) Eliminati coloana de rang k. <span style="font-family: Arial,Helvetica,sans-serif;"> c) Construiti un vector cu valorile pare din matrice in ordine inversa fata de cea in care apar in matrice (incepand cu ultima linie si de la ultima coloana pe fiecare linie).

<span style="font-family: Arial,Helvetica,sans-serif;"> 13. Sa se construiasca si sa se afiseze matricea cu n linii si n coloane de forma (exemplu pentru n = 5): <span style="font-family: Arial,Helvetica,sans-serif;"> 1 1 1 1 1 <span style="font-family: Arial,Helvetica,sans-serif;"> 2 2 2 2 2 <span style="font-family: Arial,Helvetica,sans-serif;"> 3 3 3 3 3 <span style="font-family: Arial,Helvetica,sans-serif;"> 4 4 4 4 4 <span style="font-family: Arial,Helvetica,sans-serif;"> 5 5 5 5 5 || <span style="font-family: Arial,Helvetica,sans-serif;">b) <span style="font-family: Arial,Helvetica,sans-serif;"> 1 2 2 2 1 <span style="font-family: Arial,Helvetica,sans-serif;">3 1 1 1 4 <span style="font-family: Arial,Helvetica,sans-serif;">3 1 1 1 4 <span style="font-family: Arial,Helvetica,sans-serif;">3 1 1 1 4 <span style="font-family: Arial,Helvetica,sans-serif;">1 5 5 5 1 || <span style="font-family: Arial,Helvetica,sans-serif;">c) <span style="font-family: Arial,Helvetica,sans-serif;"> 1 2 3 4 5 <span style="font-family: Arial,Helvetica,sans-serif;"> 2 3 4 5 6 <span style="font-family: Arial,Helvetica,sans-serif;"> 3 4 5 6 7 <span style="font-family: Arial,Helvetica,sans-serif;"> 4 5 6 7 8 <span style="font-family: Arial,Helvetica,sans-serif;"> 5 6 7 8 9 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">d) 1 1 1 1 1 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 1 2 2 2 2 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 1 2 3 3 3 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 1 2 3 4 4 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 1 2 3 4 5 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1 2 3 4 5 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 10 9 8 7 6 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">11 12 13 14 15 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 20 19 18 17 16 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 21 22 23 24 25 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">f) <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1 2 3 4 5 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 16 17 18 19 6 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 15 24 25 20 7 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 14 23 22 21 8 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 13 12 11 10 9 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">g) <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1 2 3 4 5 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 0 16 0 6 0 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 0 0 15 0 0 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 0 8 0 14 0 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 9 10 11 12 13 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">h) <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1 2 3 4 5 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 2 1 2 3 4 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 3 2 1 2 3 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 4 3 2 1 2 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 5 4 3 2 1 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1 10 11 20 21 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 2 9 12 19 22 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 3 8 13 18 23 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 4 7 14 17 24 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 5 6 15 16 25 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">j) <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 1 9 25 49 81 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">121 225 289 361 441 5<span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">29 625 729 841 961 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1089 1225 1369 1521 1681 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1849 2025 2209 2401 2601 || k) <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 1 2 3 4 5 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">2 4 6 8 10 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">3 6 9 12 15 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">4 8 12 16 20 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">5 10 15 20 25 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">l) <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;"> 1 2 3 4 0 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1 2 3 0 4 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1 2 0 3 3 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1 0 2 2 2 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">0 1 1 1 1 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">0 1 1 1 0 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">3 0 1 0 3 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">3 3 0 3 3 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">3 0 2 0 3 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">0 2 2 2 0 || <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">n) <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">1 2 3 4 5 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">2 3 4 5 6 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">3 4 5 6 7 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">4 5 6 7 8 <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">5 6 7 8 9 || o) 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25 || p) 5 4 3 2 1 6 7 8 9 10 15 4 13 12 11 16 17 18 19 20 25 24 23 22 21 ||
 * <span style="font-family: Arial,Helvetica,sans-serif;">a)
 * <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">e)
 * <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">i)
 * <span style="font-family: &#39;Times New Roman&#39;,&#39;serif&#39;; font-size: 16px;">m)

<span style="font-family: Arial,Helvetica,sans-serif;">14. Sa se construiasca si sa se afiseze matricea cu n linii si n coloane de forma (exemplu pentru n = 4) <span style="font-family: Arial,Helvetica,sans-serif;">a)


 * =====1===== || 2 || 3 || 4 ||
 * **5** || 6 || 7 || 0 ||
 * **8** || 9 || 0 || 0 ||
 * **10** || 0 || 0 || 0 ||

b)


 * 10 || 11 || 12 || 13 ||
 * 11 || 12 || 13 || 14 ||
 * 12 || 13 || 14 || 15 ||
 * 13 || 14 || 15 || 16 ||

c)


 * 16 || 15 || 14 || 13 ||
 * 12 || 11 || 10 || 9 ||
 * 8 || 7 || 6 || 5 ||
 * 4 || 3 || 2 || 1 ||

d)


 * 1 || 2 || 3 || 4 ||
 * 12 || 13 || 13 || 5 ||
 * 11 || 13 || 13 || 6 ||
 * 10 || 9 || 8 || 7 ||

e)


 * 1 || 0 || 0 || 8 ||
 * 0 || 2 || 7 || 0 ||
 * 0 || 6 || 3 || 0 ||
 * 5 || 0 || 0 || 4 ||

f) <span style="font-family: Arial,Helvetica,sans-serif;">g) n numar par
 * 1 || 1 || 1 || 1 ||
 * -1 || 2 || 2 || 2 ||
 * -1 || -2 || 3 || 3 ||
 * -1 || -2 || -3 || 4 ||


 * 1 || 1 || 3 || 3 ||
 * 1 || 1 || 3 || 3 ||
 * 2 || 2 || 4 || 4 ||
 * 2 || 2 || 4 || 4 ||

h)


 * 1 || 4 || 9 || 16 ||
 * 144 || 0 || 0 || 25 ||
 * 121 || 0 || 0 || 36 ||
 * 100 || 81 || 64 || 49 ||

i)


 * 1 || 1 || 1 || 0 ||
 * 2 || 2 || 0 || 4 ||
 * 3 || 0 || 3 || 4 ||
 * 0 || 2 || 3 || 4 ||