有以下程序: #include #define N 4 int fun(int a[][N]) {int i,j,x=0; for(i=0;i

admin2016-04-07  17

问题 有以下程序:
    #include
    #define N 4
    int fun(int a[][N])
    {int i,j,x=0;
    for(i=0;i    for(j=0;j    if(i==j)
    x+=a[N一1—j]
    return x;   
    }
    main()   
    {int X[N][N]={{1,2,3,4},
    {5,6,7,8},
    {9,10,11,12}’
    {13,14,15,17}},y;
    Y=fun(X);
    printf("%d\n",y);
    }
    程序运行后的输出结果是(    )。

选项 A、34
B、35
C、2s
D、59

答案A

解析 fun()函数求矩阵反对角线的元素之和。根据:tun()函数,当数组的行列下标相等时,对该行反对角线上的元素求和。故结果为4+7+11+13=34,答案为A选项。
转载请注明原文地址:https://kaotiyun.com/show/GtDp777K
0

随机试题
最新回复(0)