柠檬试题库
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,400
参考答案: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年计算机等级考试题库
推荐
支持子程序调用的数据结构是( )。
有如下事件程序,运行该程序后输出结果是( )。 Private Sub Command33_Click() Dim x As Integer,y As Integer x=1:y=0 Do Until y<=25 y=y+x*x x=x+1 Loop MsgBox "x=" & x & ",y=" & y End Sub
假定有以下两个过程: Sub s1(ByVal x As Integer,ByVal y As Integer) Dim t As Integer t=x x=y y=t End Sub Sub S2(x As Integer,y As Integer) Dim t As Integer t=x:x=y:y=t End Sub 下列说法正确的是( )。
以下关系表达式中,其值为True的是( )。
标签
二级C语言
for
循环
执行
进入