以下程序的输出结果是 #include int a[3][3]={1,2,3,4,5,6,7,8,9,},*p; main( ) { p=(int *)malloc(sized(int)); f(p,a) ;

admin2010-09-05  14

问题 以下程序的输出结果是
   #include
   int a[3][3]={1,2,3,4,5,6,7,8,9,},*p;
   main( )
   { p=(int *)malloc(sized(int));
     f(p,a) ;
     printf("%d\n",*p);
     free(p);}
     f(int *s,int p[ ][3])
   { *s=p[1][1];}

选项 A、1
B、4
C、7
D、5

答案D

解析 本题考查了二维数组元素引用的方法。题中用动态存储分配函数malloc分配了一个int型数据长度大小的内存,然后指针p指向了这段内存,函数f( )中对p所指向的数据进行了赋值,p[1][1]为二维数组第二行第二列的元素,对应于实参a的元素5,所以输出结果为5。
转载请注明原文地址:https://kaotiyun.com/show/HMWp777K
0

最新回复(0)