二维数组用一维数组怎么表示的?
发布网友
发布时间:2023-07-04 22:02
我来回答
共2个回答
热心网友
时间:2024-03-07 19:20
sz[1][32]={
{0xff,0xfe,0xff,0xfd,0xff,0xfb,0xff,0xf7,
0xff,0xef,0xff,0xdf,0xff,0xbf,0xff,0x7f,
0xfe,0xff,0xfd,0xff,0xfb,0xff,0xf7,0xff,
0xef,0xff,0xdf,0xff,0xbf,0xff,0x7f,0xff}
};
这是数组定义,表示数组共有有1行,32列,它的首行首列是从sz[0][0]开始到sz[0][31]
sz[0][j]是指第一行第 j 个数的值,比如sz[0][3]=0xff,
sz[0]是指第一行sz[0]={0xff,0xfe,0xff,0xfd,0xff,0xfb,0xff,0xf7,
0xff,0xef,0xff,0xdf,0xff,0xbf,0xff,0x7f,
0xfe,0xff,0xfd,0xff,0xfb,0xff,0xf7,0xff,
0xef,0xff,0xdf,0xff,0xbf,0xff,0x7f,0xff}追问sz[0]=是指向首地址的,唉唉,我没有说清楚,因为还有个指针定义了。
热心网友
时间:2024-03-07 19:20
比如
C/C++
#include <stdio.h>
int main()
{
int a[2][3];
int i;
for(i=0;i<6;i++)
{
*(*a+i)=i;
}
for(i=0;i<6;i++)
{
printf("%3d",*(*a+i));
}
return 0;
}