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

9 查阅

以下程序的输出结果是 #include<stdio.h> int a[3][3]={1,2,3,4,5,6,7,8,9,},*p; main() { p=(int*)malloc(sizeof(int)); f(p,a); printf("%d\n”,*p); free(p);} f(int *s,intp [][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。

计算机二级