练习03-17-01
输出样例:
The original matrix:
89 87 88 59
64 47 60 38
3 96 35 68
Input x (0~2) and y(0~3)
x=0
y=0
a[0][0]=89
--------------------------------
Process exited after 5.918 seconds with return value 0
请按任意键继续. . .
代码如下:
//输出二维数组中的任一行任一列元素的值
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
srand((unsigned)time(NULL));
int a[3][4],i,j;
printf("The original matrix:\n");
for(i=0;i<3;++i){
for(j=0;j<4;++j){
a[i][j]=rand()%100;
printf("%3d",a[i][j]);
}putchar('\n');
}
printf("Input x (0~2) and y(0~3)\n");
printf("x=");
scanf("%d",&i);
putchar('\n');
printf("y=");
scanf("%d",&j);
int (*p)[4]=a;
printf("\na[%d][%d]=%d",i,j,*(*(p+i)+j));
return 0;
}