首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include<stdio.h> #define N 4 void fun(int a[][N],int b[]) { int i; for(i=0;i<N;i++) b[i]=a[i][i];
有以下程序: #include<stdio.h> #define N 4 void fun(int a[][N],int b[]) { int i; for(i=0;i<N;i++) b[i]=a[i][i];
admin
2020-10-26
33
问题
有以下程序:
#include<stdio.h>
#define N 4
void fun(int a[][N],int b[])
{
int i;
for(i=0;i<N;i++)
b
=a
;
}
main()
{
int x[][N]=({1,2,3},{4},{5,6,7,8},{9,10}},y[N],i;
fun(x,y);
for(i=0;i<N;i++)
printf("%d",y
);
printf("\n");
}
程序运行的结果是( )。
选项
A、1 2 3 4
B、1 0 7 0
C、1 4 5 9
D、3 4 8 0
答案
B
解析
数组x有4列。fun函数中for循环的作用是将二维数组前4行的对角线元素分别赋给b[0],b[1],b[2],b[3]。在主函数中,二维数组初始化为{1,2,3},{4},{5,6,7,8},{9,10},所以可以看出对角线元素为1 0 7 0。
转载请注明原文地址:https://www.kaotiyun.com/show/Wx3p777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下叙述中正确的是
有以下程序段inti,n;for(i=0;i<8;i++){n=rand()%5;switch(n){case1:case3:printf("%d\n",n);break;case2:case4:printf("%d\n",n);cont
有以下说明和定义语句structstudent{intage;charnum[8];};structstudentstu[3]={{20,"200401"},{21,"200402"},{19,"200403"}};structstud
下列关于栈叙述正确的是
下列描述中,不符合良好程序设计风格要求的是()。【07年9月】
若函数中有定义语句:intk;则()。
若有定义语句inta,b;doublex;,则下列选项中没有错误的是()。【10年9月】
若有如下定义语句:doublex,y,*px,*py;执行了px=&x;py=&y;之后,正确的输入语句是()。
以下语句中存在语法错误的是
随机试题
根据合伙企业法律制度的规定,下列各项中,属于合伙企业财产的有()。
A.肩井、缺盆B.哑门、风府C.中极、大赫D.期门、日月
在腹前壁上第4腰椎的体表定位点是
携带胆固醇最多的脂蛋白是
项目工作开展的基础是()。
2022年1月,某酒厂(增值税一般纳税人)销售粮食白酒和啤酒给副食品公司,其中白酒开具增值税专用发票,收取不合税价款50000元,另外收取包装物押金3000元;啤酒开具普通发票,收取的价税合计款20730元,另外收取包装物押金1500元。副食品公司按合同约
Finally,carefulprioritizationisnoalternativetotheadequate______ofthesciencebase.
(1)Youshouldtreatskepticallytheloudcriesnowcomingfromcollegesanduniversitiesthatthelastbastionofexcellencein
PASSAGEONEWhatdidyoungGandhi’sbehavior,liketakingdancinglesson,indicate?
A、Hiswatchdistractedhimduringthefilm.B、Healmostmissedthefilm.C、Thefilmfailedtomeethisexpectations.D、Thefilm
最新回复
(
0
)