<span style= "FONT-SIZE:14PX;" > #include <stdio.h> #include <stdlib.h>//two-dimensional array assignment void Show2 () {int a[3][4]; int k=0; for (int i=0;i<3;i++) {for (int j=0;j<4;j++) {a[i][j]=i*4+ (j+1);//Mathematical formula assignment//A I [j]= ++k;//is consistent with the above effect printf ("%-6d", A[i][j]); } printf ("\ n"); }}//one-dimensional array assignment void Show1 () {int a[3][4]; int k=0,count=0; for (int i=0;i<12;i++) {//25/10=2,25%10=5;78/10=7,78%10=8, which is divided by 10 to get 10 bits, modulo 10 gets a bit, equivalent to a horizontal axis x, an ordinate y//with the second subscript as The Datum (that is, the addition and the remainder are calculated by Y) a[i/4][i%4]=i;//one-dimensional array initialization a[i/4][i%4]=++k; count++; printf ("%-6d", a[i/4][i%4]); if (count%4==0) {printf ("\ n"); }}}int Main () {show2 (); Show1 (); An int a[3][4]={0};//two-bit array is assigned a value of 0, then all 0//two-dimensional arrays can be treated as a one-dimensional array, and each element is a one-dimensional array of int a[3][4]={{1,2},{5,6,7,8},{9,10,11,12}}; After the int a[][4]={{1,2,3,4}};//Curly brace is initialized, the line coordinates can be omitted from printf ("%d\n", sizeof (a)); Column coordinates cannot be omitted because two-dimensional arrays, each elementAnother one-dimensional array, the length of a one-dimensional array can not omit//int a[3][]={{0},{0},{0}};//error//n-dimensional array, curly brace initialization has certain factors, only the first can omit return 0;} </span>
Two-dimensional dynamic array
Two modes
The first overall sort is sequential. Use as a static two-dimensional array
The second whole is discontinuous, an array of pointers, each element being a pointer, storing the address of another array
One-dimensional arrays, two-dimensional arrays are initialized with mathematical formulas, and the row coordinates of two-dimensional arrays can be saved