0 ) { switch(s) { case 1: printf("%d", s+5); case 2: printf("%d", s+" />
有以下程序 #include main() { int s; scanf("%d", &s); while( s>0 ) { switch(s) { case 1: printf("%d", s+5); case 2: printf("%d", s+
首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
0 ) { switch(s) { case 1: printf("%d", s+5); case 2: printf("%d", s+">有以下程序 #include main() { int s; scanf("%d", &s); while( s>0 ) { switch(s) { case 1: printf("%d", s+5); case 2: printf("%d", s+
有以下程序 #include main() { int s; scanf("%d", &s); while( s>0 ) { switch(s) { case 1: printf("%d", s+5); case 2: printf("%d", s+
admin
2015-07-28
44
问题
有以下程序
#include
main()
{ int s;
scanf("%d", &s);
while( s>0 )
{ switch(s)
{ case 1: printf("%d", s+5);
case 2: printf("%d", s+4); break;
case 3: printf("%d", s+3);
default: printf("%d", s+1); break;
}
scanf("%d", &s);
}
}
运行时,若输入1 2 3 4 5 0<回车>,则输出结果是( )。
选项
A、6566456
B、66656
C、66666
D、6666656
答案
A
解析
程序的循环条件是s>0,也就是不断读入数据并存放到s中直到输入的数据为非正,循环体的switch语句会判定s的值,然后选定一个case作为执行入口,不断向下执行直到遇到break;,易知s为1时,输出s+5和s+4的值;s为2时,只输出s+4的值;s为3时输出s+3和s+1的值;其他情况输出s+1的值,答案选A。
转载请注明原文地址:https://kaotiyun.com/show/FOJp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下程序的输出结果,是_______。main(){charstr[12]={’s’,’t’,’r’,’i’,’n’,’g’};printf("%d\n",strlen(str));}
下面程序的输出结果是_______。unsignedfun(unsignednum){unsignedk=1;do{k*=num%10;num/=10;}whil
设整型数i=5,则printf("%d",i+++++i);的输出为_______。
请选出以下程序的输出结果_______。#include<stdio.h>sub(x,y,z)intx,y,*z;{*z=y-x;}main(){inta,b,c;sub(10,5,&A)
有程序 #include<stdio.h> main() {inta,b,c=246; a=c/100%9; b=(-)&&(-1); printf("%d,%d\n%,a,b); } 输出结果是()
执行以下程序段后,m的值为() inta[2][3]={{1,2,3}{4,5,6}}; intm,*p; p=&a[0][0] m=(*p)*(*p+2))*(*(p+4));
下列程序执行后的输出结果是() main() {inta[3][3],*p,i; p=&a[0][0]; for(i=0;i<9;i++)p[i]=i+1; printf("%d\n",a[1][2]); }
以下叙述中正确的是______。
以下叙述中正确的是
随机试题
钱某为某市一个体工商户,从事服装生意,月收入上万元。因仗着自己财大气粗,钱某在市场上得罪了许多竞争对手。在一次税务大检查当中,税务局收到许多举报,称钱某偷漏税款严重。负责钱某所在市场税收检查的税务所派出几名工作人员将钱某强行拘留,关在税务所办公室中,令其交
触媒使用初期触媒活性高超负荷生产对触媒没有损害。
患儿,1岁。高热、呕吐10小时。面色灰暗,嗜睡,前囟隆起,颈软,怀疑化脓性脑膜炎,为协助诊断最重要的检查是
从房地产开发程度上划分,房地产可分为土地和建筑物两种类型。()
从我国会计工作实情出发,建立单位内部会计监督制度,应当遵循的原则有()。
“乐”和“热”的发音是相同的,它们的声母都是1。()
设线性方程组(1)Ax=0的一个基础解系为α1=(1,1,1,0,2)T,α2=(1,1,0,1,1)T,α3=(1,0,1,1,2)T。线性方程组(2)Bx=0的一个基础解系为β1=(1,1,一1,一1,1)T,β2=(1,一1,1,一1,2)T,β3=
对线性表进行二分法检索,其前提条件是______。
PreventingChildMaltreatmentChildmaltreatmentisaglobalproblemwithseriouslife-longconsequences.Therearenorelia
I’mworriedaboutwashingthatshirtincaseit______.
最新回复
(
0
)