current position:Home>Definition of two-dimensional array in C language

Definition of two-dimensional array in C language

2022-02-03 00:38:29 CSDN Q & A

int a[2][3]={ {1},{2},{3,4}}; Why is it wrong




Refer to the answer 1:

{1},{2},{3,4} Here you are 3 individual {}, Should be int a[3][3]
The number of rows and columns can be more than the number in initialization , But not less .
The smallest two-dimensional array in this topic is 3 That's ok 2 Column , therefore , The smallest two-dimensional array is int a[3][2], The number of rows of the array must be greater than or equal to 3, The number of columns must be greater than or equal to 2.
int a[3][2] ={ {1},{2},{3,4}};
int a[3][3] ={ {1},{2},{3,4}};
int a[4][2] ={ {1},{2},{3,4}};
int a[4][3]={ {1},{2},{3,4}};
These kinds of writing are OK .




Refer to the answer 2:



Refer to the answer 3:

You wrote this column backwards , Change to a[3][2] That's right ,2 and 3 Turn it upside down
Should be
int a[3][2]={ {1},{2},{3,4}};




Refer to the answer 4:



Refer to the answer 5:

int a[5][3]={ {80,75,92}, {61,65,71}, {59,63,70}, {85,87,90}, {76,77,85} }; Like this ,
Look at your { {1},{2},{3,4}}, Let's look at the definition of two dimensions




Refer to the answer 6:



Refer to the answer 7:

In a multidimensional array , The first represents the outermost memory space , And so on , So you put int a[2][3] It is amended as follows int a[3][3] That's it , Are the most basic grammatical concepts ! Must master




Refer to the answer 8:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030038269294.html

Random recommended