柠檬试题库
search
首页
计算机
公务员
驾照
关于
share
若有以下程序 #include
main() { int s=0, n; for (n=0; n<4; n++) { switch(n) { default: s+=4; case 1: s+=1; case 2: s+=2; case 3: s+=3; } } printf("%d\n", s); } 则程序的输出结果是
A.6
B.18
C.10
D.24
热度🔥3,491
参考答案:D
解析:
【解析】第一次for循环,n的值为0,所以从default后面的语句开始执行,s+=4,s+=1,s+=2,s+=3,s的值为10。在进入第二次for循环,n的值为1,所以执行s+=1,s+=2,s+=3,s的值为16。在进入第三次for循环,n的值为2,所以执行s+=2,s+=3,s的值为21。在进入第四次for循环,n的值为3,所以执行s+=3,s的值为24。
复制题目向AI提问
content_copy
content_copy
扫码免费计算机二级刷题
2025年计算机等级考试题库
推荐
算法的有穷性是指( )。
有以下程序 #include #include void fun( int *p1, int *p2, int *s) { s=( int*)calloc(1,sizeof(int)); *s=*p1+*p2; free(s); } main() { int a[2]={1,2}, b[2]={40,50},*q=a; fun(a,b,q); printf("%d\n", *q); } 程序运行后的输出结果是
与个人计算机(PC)相比,嵌入式系统具有许多不同的特点。下面不属于嵌入式系统特点的是:( )。
数据库系统的三级模式不包括( )。
标签
二级C语言
for
循环
执行
进入