1 #include <stdio.h>
2
3
4 int main(int argc,char *argv[])
5 {
6
7 int a[][3] = {{1,2,3},{4,5,6},{7,8,9}};
8
9 int (*P)[3]=a;
10
11
12
13 printf("---1-----(1,1)=%d----------\r\n",*P[0]);
14 printf("---3-----(1,3)=%d----------\r\n",*P[0]+2);
15 printf("---5-----(2,2)=%d----------\r\n",*P[1]+1);
16 printf("---7-----(3,1)=%d----------\r\n",*P[2]);
17 printf("---9-----(3,3)=%d----------\r\n",*P[2]+2);
18
19
20 return 0;
21 }
运行结果:
-------------------------------------------------遍历二维数组---------------------------------------------------------
1 #include <stdio.h>
2
3
4 int main(int argc,char *argv[])
5 {
6
7 int a[][3] = {{1,2,3},{4,5,6},{7,8,9}};
8 // int a[][3] = {1,2,3,4,5,6,7,8,9};
9
10 int (*P)[3]=a;
11
12 for(int i=0;i<=2;i++)
13 for(int j=0;j<=2;j++)
14 {
15 static int t=0;
16 printf("----loop%d------number=%d\r\n",t++,*P[i]+j);
17 }
18
19 return 0;
20 }
运行结果: