二维数组中没写的数据,默认0补充,
二维数组可以不写行数,但是要写列数。
#include <stdio.h>
int main()
{
int array[2][3] = {21,45,65,341,52,45};
int array1[2][3] = {{2,4},{23}};//默认的为0
int array2[][3] = {21,45,65,341,52,45};//可以不写行,但是要写列
int i,j;
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",array[i][j]);
}
putchar('\n');
}
puts("==============");
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",array1[i][j]);
}
putchar('\n');
}
puts("==============");
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",array2[i][j]);
}
putchar('\n');
}
return 0;
}