What Is a Transpose Array?

Two-dimensional arrays are essentially arrays with arrays as array elements, that is, "arrays of arrays", type specifier array name [constant expression] [constant expression]. A two-dimensional array is also called a matrix, and a matrix with the same number of rows and columns is called a square matrix. Symmetric matrix a [i] [j] = a [j] [i], diagonal matrix: n-th order square matrix has zero elements outside the main diagonal.

E.g:
float a [3] [4], b [5] [10];
Define a as an array of 3 * 4 (3 rows and 4 columns), and b as an array of 5 * 10 (5 rows and 10 columns). Note that it cannot be written as
float a [3,4], b [5,10];
To facilitate understanding, a C language program and its results are added:
 #include <stdio.h> int main (int argc, const char * argv []) {int array [3] [5] = {0}; // Define a two-dimensional array (3 rows and 5 columns) int temp = 0; // Set a temporary integer variable to assign the value to the array for (int a = 0; a <3; a ++) // The outer loop assigns the value to the first dimension of the array, which is array [x] [ x for y] {for (int b = 0; b <5; b ++) // The inner loop assigns a value to the second dimension of the array, which is the y of array [x] [y] {temp = temp + 1; // In order to make the values of the arrays different, let the temporary variables have incremented array [a] [b] = temp; a, b, array [a] [b]); // Print out the array} printf ("\ n"); // Wrap a line after outputting a line} return 0;} 
The results are (for easy viewing, organized into a table):
array [0] [0] = 1 array [0] [1] = 2 array [0] [2] = 3 array [0] [3] = 4 array [0] [4] = 5
array [1] [0] = 6 array [1] [1] = 7 array [1] [2] = 8 array [1] [3] = 9 array [1] [4] = 10
array [2] [0] = 11 array [2] [1] = 12 array [2] [2] = 13 array [2] [3] = 14 array [2] [4] = 15
Two-dimensional
C ++ dynamic two-dimensional array:
Take integer as an example, row is the number of rows and col is the number of columns
int ** data; // Two-dimensional storage
  • matrix
  • sparse matrix

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?