有以下程序,输出结果( )。 #include<iostream.h> void main() {static int b[][3]={{1,2,3},{4},{5,6}}; b[0][2]=12,b[1][2]=18

admin2020-11-11  20

问题 有以下程序,输出结果(    )。
    #include<iostream.h>
    void main()
    {static int b[][3]={{1,2,3},{4},{5,6}};
    b[0][2]=12,b[1][2]=18;
    cout<<**b<<’’\t’’<<**(b+1)
<<’’\t’’<<**(b+1)<<’’\t’’<<*(*(b+1)+2)<<’’\n’’;
    cout<<b[0][2]+b[1][2]+b[2][2]<<end1;
    }

选项 A、1  4  4  18  30
B、1  1  4  4  18
C、4  4  18  1  1
D、4  4  4  30  1

答案A

解析 本题b是一个3×3的二维数组:利用指针表示数组:*(*(数组名+i)+j)。**b表示b[0][0]元素,值是1,**(b+1)表示是b[0][1]的元素,值是4。*(*(b+1)+2)表示b[1][2]的元素,值是18,b[0][2]+b[1][2]+b[2][2]之和是30。
转载请注明原文地址:https://kaotiyun.com/show/Kcyp777K
0

最新回复(0)