首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include <stdio.h> main() { int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y)
有以下程序 #include <stdio.h> main() { int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y)
admin
2010-09-05
25
问题
有以下程序 #include <stdio.h> main() { int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y) { case 0:a++; break; case 1:b++; break; } case 2:a++;b++; break; case 3:a++;b++; } printf("a=%d,b=%d\n",a,b); } 程序的运行结果是
选项
A、a=1,b=0
B、a=2,b=2
C、a=1,b=1
D、a=2,b=1
答案
D
解析
本题考查switch语句,首先,x=1符合条件case 1,执行switch(y)语句。y=0符合case 0语句,执行 a抖并跳出switch(y)语句,此时a=1。因为case 1语句后面没有break语句,所以向后执行case 2语句,执行a++,b++,然后跳出switch(x),得a=2,b=1。
转载请注明原文地址:https://kaotiyun.com/show/ycWp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
在窗体上画一个命令按钮,然后编写如下事件过程:PrivateSubCommand1Clickf)Fori=1To4X=4Forj=1To3X=3Fork=1to2
在考生文件夹下有一个工程文件sjt5.vbp,按照要求完成以下操作:在名称为Form1的窗体上添加两个命令按钮,其名称分别为C1和C2,标题分别为“读入数据”和“计算”(如图所示)。程序运行后,如果单击“读入数据”按钮,则调用题目所提供的Read
数据库设计过程不包括
以下关于过程及过程参数的描述中,错误的足()。
以下关于控件数组的叙述中,正确的是( )。
窗体如图1所示。要求程序运行时,在文本框Text1中输入一个姓氏,单击"删除"按钮(名称为Command1),则可删除列表框List1中所有该姓氏的项目。若编写以下程序来实现此功能:PrivateSubCommand1_Click() Dimn%
设窗体文件中有下面的事件过程:PrivateSubCommand1_Click() Dims a%=100 PrintaEndSub其中变量a和s的数据类型分别是( )。
如果要定义一个窗体级变量,定义变量语句的位置应该是
内聚性是对模块功能强度的衡量,下列选项中,内聚性较弱的是()。
随机试题
A.输卵管子宫部B.输卵管峡部C.输卵管壶腹部D.输卵管漏斗部E.输卵管伞卵子受精的部位通常是
以下说法中,正确的是()。
what,which,that,is,are,wasWhathedidand_______hesaid_______totallydifferent.
Thereappeartobepeakperiodsinthedaywhenweareatourzaniest(荒谬可笑的).Thesearetwohourssometimebetweeneighta.m.
麦角生物碱与缩宫素均可用于
商品流通企业库存管理的目标是“零库存”。在实际工作中,接近于“零库存”的库存控制策略是()。
关于打击与保护,下列说法正确的是()。
公安机关的宗旨是对人民实行民主,对敌人实行专政。()
阅读下列材料,回答问题。开展××市农村优秀教师评定工作的决定各区(县、市)教育局:根据××
设从z轴正向看,L为逆时针,则∮Lydx-(2z+1)dy+2xdz=________.
最新回复
(
0
)