Grade 10 · 15 algorithmsCitește în română
Two-dimensional arrays (matrices)Tablouri bidimensionale (matrice)
Every two-dimensional arrays (matrices) algorithm from the Romanian high school curriculum, with the idea explained, its complexity, examples and code you can edit and run right here.
- 15algorithms
- 6chapters
- 1grade
15 algorithms
0%
Two-dimensional arrays (matrices)
Tablouri bidimensionale (matrice) · 15 algorithms
- Bordering a matrixBordarea matriceiBordering a matrix means adding a new row and/or column on its edge. Here we add column m + 1, holding the sum of each row, and row n + 1, holding…
- Reading and printing a matrixCitirea și afișarea unei matriceA matrix with n rows and m columns is declared as int a[101][101] and traversed with two nested for loops: the first picks the row i, the second the…
- Main diagonal and secondary diagonalDiagonala principală și diagonala secundarăIn an n x n square matrix indexed from 1, the elements on the main diagonal have i == j, and those on the secondary diagonal have i + j == n + 1. We…
- Row with the maximum sumLinia cu suma maximăWe compute the sum of every row and compare it with the largest sum found so far. The maximum starts from the sum of the first row (not from 0,…
- Generating a serpentine (zigzag) matrixGenerarea matricei în serpentinăWe fill the matrix with the numbers 1, 2, ..., n * m in a zigzag: odd rows from left to right, even rows from right to left. A counter val grows…
- Checking a symmetric matrixVerificarea matricei simetriceA square matrix is symmetric about the main diagonal if a[i][j] == a[j][i] for every i and j (it equals its transpose). It is enough to check the…
- Spiral traversalParcurgerea în spiralăWe keep four borders: top, bottom, left, right. On every lap we walk the top row (to the right), the right column (down), the bottom row (to the…
- Product of two matricesProdusul a două matriceThe product exists only if the number of columns of A equals the number of rows of B. For A (n x m) and B (m x p) the result C has n x p elements,…
- Saddle pointPunct șaA saddle point is an element that is the minimum of its row and the maximum of its column. For every element a[i][j] we check the two conditions…
- Rotating a matrix by 90 degreesRotirea unei matrice cu 90 de gradeWhen rotating clockwise, the first column read from bottom to top becomes the first row. The result matrix b has m rows and n columns, and the…
- Deleting a row and a columnȘtergerea unei linii și a unei coloaneAs with arrays, deleting means moving elements over the deleted one. For row k, every row i from k to n - 1 receives row i + 1, then n decreases by…
- Row sums and column sumsSuma pe linii și pe coloaneFor the sum of row i we keep i fixed and move j from 1 to m. For the sum of column j we do the opposite: j fixed in the outer loop, i varying in the…
- Generating a chessboardGenerarea tablei de șahOn a chessboard, the colour of a square depends only on the parity of i + j: squares with an even i + j have one colour (1), those with an odd i + j…
- Transpose of a matrixTranspusa unei matriceThe transpose of the matrix a (n rows, m columns) has m rows and n columns: row i of the transpose is column i of a, i.e. t[j][i] = a[i][j]. No…
- The four zones of a square matrixCele patru zone ale matricei pătraticeThe two diagonals split a square matrix into four zones (without the elements on the diagonals). With indices from 1: North: i < j and i + j < n + 1…