经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

【选择题】第6章:循环控制结构 例题

📝 题解 🔵 仅限 C++
题目描述
<p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;"> 1、&nbsp;以下程序段的输出结果是( &nbsp; &nbsp;) </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;"> <span style="line-height:1.5;">&nbsp; &nbsp; A) 9 &nbsp; &nbsp;B) 1 &nbsp; C) 11 &nbsp; &nbsp;D) 10</span> </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;int&nbsp;k,j,s; </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;for&nbsp;(k=2;k&lt;6;k++,k++) </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;{&nbsp; </p> <p class="p0" style="margin-left:21.0000pt;"> s=1; </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp; for&nbsp;(j=k;&nbsp;j&lt;6;&nbsp;j++)&nbsp;s+=j;&nbsp; </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;} </p> <p class="p0" style="margin-left:21.0000pt;"> printf(“%d\n”,s); </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;"> 2、&nbsp;以下程序段的输出结果是( &nbsp; &nbsp;) </p> <p class="p0"> &nbsp;&nbsp;&nbsp;&nbsp;A) 12 &nbsp; &nbsp;B) 15&nbsp;&nbsp;&nbsp; C) 20 &nbsp; &nbsp;D) 25 </p> <p class="p0" style="margin-left:21.0000pt;"> int&nbsp;i,j,m=0; </p> <p class="p0" style="margin-left:21.0000pt;"> for&nbsp;(i=1;i&lt;=15;i+=4) </p> <p class="p0" style="margin-left:21.0000pt;"> for&nbsp;(j=3;j&lt;=19;j+=4)m++; </p> <p class="p0" style="margin-left:21.0000pt;"> printf(“%d\n”,m); </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;"> 3、&nbsp;以下程序段的输出结果是( &nbsp; &nbsp;) </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;&nbsp;int&nbsp;n=10&nbsp;; </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;while&nbsp;(n&gt;7) </p> <p class="p0" style="margin-left:21.0000pt;"> {&nbsp; </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;n--; </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;&nbsp;printf(“%d\n”,n);&nbsp; </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;} </p> <p class="p0" style="margin-left:21.0000pt;"> <span style="line-height:1.5;">A)&nbsp;&nbsp;10&nbsp;&nbsp; B)&nbsp;9&nbsp;&nbsp;&nbsp;&nbsp;C)&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;D)&nbsp;9</span> </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp; &nbsp; &nbsp; &nbsp;9 &nbsp; &nbsp; &nbsp; 8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;9 &nbsp; &nbsp; &nbsp; &nbsp;8 </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp; &nbsp; &nbsp; &nbsp;8 &nbsp; &nbsp; &nbsp; 7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;8 &nbsp; &nbsp; &nbsp; &nbsp;7 </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;7 &nbsp; &nbsp; &nbsp; &nbsp;6 </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;"> 4、&nbsp;以下程序段的输出结果是( &nbsp; &nbsp;) </p> <p class="p0" style="margin-left:21.0000pt;"> A)&nbsp;1 &nbsp; &nbsp;B) 3&nbsp;0 &nbsp; &nbsp;C)&nbsp;1&nbsp;–2 &nbsp; &nbsp;D) 死循环 </p> <p class="p0" style="margin-left:21.0000pt;"> int&nbsp;x=3; </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;do&nbsp; </p> <p class="p0" style="margin-left:21.0000pt;"> { </p> <p class="p0" style="margin-left:21.0000pt;"> printf(“%3d”,x-=2); </p> <p class="p0" style="margin-left:21.0000pt;"> }while&nbsp;(!(--x)); </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;"> 5、&nbsp;以下程序的输出结果是( &nbsp; &nbsp;) </p> <p class="p0" style="margin-left:21.0000pt;"> A)&nbsp;741&nbsp; B)&nbsp;852&nbsp; C)&nbsp;963&nbsp; D)&nbsp;875421 </p> <p class="p0" style="margin-left:21.0000pt;"> #include&nbsp;&lt;stdio.h&gt;&nbsp; </p> <p class="p0" style="margin-left:21.0000pt;"> void&nbsp;main() </p> <p class="p0" style="margin-left:21.0000pt;"> {&nbsp; </p> <p class="p0" style="margin-left:21.0000pt;"> int&nbsp;y=10; </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp;for&nbsp;(&nbsp;;y&gt;0;y--) </p> <p class="p0" style="margin-left:21.0000pt;"> if&nbsp;(y%3==0) </p> <p class="p0" style="margin-left:21.0000pt;"> &nbsp; {&nbsp;printf(“%d”,--y);&nbsp;continue;} </p> <p class="p0" style="margin-left:21.0000pt;"> } </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;"> 6、&nbsp;以下程序的输出结果是( &nbsp; &nbsp;) </p> <p class="p0"> &nbsp;&nbsp;&nbsp;&nbsp;A)&nbsp;*#*#*#$&nbsp;&nbsp;&nbsp;B)&nbsp;#*#*#*$&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C)&nbsp;*#*#$&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;D)&nbsp;#*#*$ </p> <p class="p0" style="margin-left:21.0000pt;"> #include&nbsp;&lt;stdio.h&gt; </p> <p class="p0" style="margin-left:21.0000pt;"> void&nbsp;main(&nbsp;) </p> <p class="p0" style="margin-left:21.0000pt;"> {&nbsp; </p> <p class="p0" style="margin-left:31.5000pt;"> int&nbsp;i;&nbsp; </p> <p class="p0" style="margin-left:31.5000pt;"> &nbsp;&nbsp;for&nbsp;(i=1;i&lt;=5;i++) </p> <p class="p0" style="margin-left:31.5000pt;"> {&nbsp;if&nbsp;(i%2)&nbsp;printf(“*”); </p> <p class="p0" style="margin-left:31.5000pt;text-indent:10.2900pt;"> else&nbsp;&nbsp;continue; </p> <p class="p0" style="margin-left:31.5000pt;text-indent:10.2900pt;"> printf(“#”); </p> <p class="p0" style="margin-left:31.5000pt;"> } </p> <p class="p0" style="margin-left:31.5000pt;"> printf(“$\n”); </p> <p class="p0" style="margin-left:21.0000pt;"> } </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;vertical-align:;"> 7、&nbsp;设i和x都是int类型,则for循环语句( &nbsp; &nbsp;) &nbsp; &nbsp; &nbsp;&nbsp; </p> <p class="p0" style="margin-left:39.0000pt;"> for(i=0,x=0;i&lt;=9&amp;&amp;x!=876;i++)&nbsp;scanf("%d",&amp;x); </p> <p class="p0"> A) 最多执行10次&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B) 最多执行9次 </p> <p class="p0"> C) 是无限循环 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;D) 循环体一次也不执行 </p> <p class="p0"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;vertical-align:;"> 8、&nbsp;下述for循环语句( &nbsp; &nbsp;) </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;vertical-align:;"> <span style="line-height:1.5;">int&nbsp;i,k;</span> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;vertical-align:;"> <span style="line-height:1.5;">for(i=0,k=-1;k=1;i++,k++)&nbsp;&nbsp;printf("*&nbsp;*&nbsp;*&nbsp;*");</span> </p> <p class="p0"> A) 判断循环结束的条件非法&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B) 是无限循环 </p> <p class="p0"> C) 只循环一次 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;D) 一次也不循环 </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;vertical-align:;"> 9、&nbsp;程序段如下:则以下说法中正确的是( &nbsp; &nbsp;) </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;vertical-align:;"> <span style="line-height:1.5;">int&nbsp;k=-20;</span> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;vertical-align:;"> <span style="line-height:1.5;">while(k=0)&nbsp;k=k+1;</span> </p> <p class="p0"> A) while循环执行20次 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B) 循环是无限循环 </p> <p class="p0"> C) 循环体语句一次也不执行&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;D) 循环体语句执行一次 </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;vertical-align:;"> 10、&nbsp;若有“int&nbsp;a=1,x=1;”,则循环语句“while(a&lt;10)&nbsp;x++;&nbsp;a++;”的循环执行( ) </p> <p class="p0" style="margin-left:21.0000pt;text-indent:-21.0000pt;vertical-align:;"> <span style="line-height:1.5;">A) 无限次    &nbsp;B) 不确定次    C) 10次      D) 9次</span> </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p15" style="margin-left:21.0000pt;text-indent:-21.0000pt;"> 11、&nbsp;下列循环语句中有语法错误的是( &nbsp; &nbsp; )&nbsp; </p> <p class="p15"> A) while(x=y)&nbsp;5; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B) while(0)&nbsp;; </p> <p class="p15"> <span style="line-height:1.5;">C) do&nbsp;2;while(x=&nbsp;=b);&nbsp;D) do&nbsp;x++&nbsp;&nbsp;while(x=&nbsp;=10);</span> </p> <p class="p0" style="text-indent:21.0000pt;"> <br /> </p> <p class="p0" style="margin-left:14.2000pt;text-indent:-14.2000pt;vertical-align:;"> 12、&nbsp;执行语句for&nbsp;(&nbsp;i=0;&nbsp;&nbsp;i++&lt;3&nbsp;;)&nbsp;后,变量i的值为(&nbsp;&nbsp;&nbsp;&nbsp;) </p> <p class="p0"> A) 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B) 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C) 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;D) 5 </p> <p class="p0" style="margin-left:21.0000pt;"> <br /> </p> <p class="p15" style="margin-left:14.2000pt;text-indent:-14.2000pt;"> 13、&nbsp;执行语句{for(j=0;j&lt;=3;j++)&nbsp;a=1;}后变量j的值是( &nbsp; &nbsp; ) &nbsp; &nbsp; &nbsp;&nbsp; </p> <p class="p15" style="margin-left:14.2000pt;text-indent:-14.2000pt;"> <span style="line-height:1.5;">A) 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B)&nbsp;3 &nbsp; &nbsp; &nbsp; &nbsp; C) 4 &nbsp; &nbsp; &nbsp; &nbsp; D)&nbsp;1</span> </p> <p class="p15" style="margin-left:31.5000pt;"> <br /> </p>
输入格式
输出格式
<span style="font-family:'Microsoft Yahei';font-size:14px;line-height:28px;background-color:#F5F5F5;">#include&lt;stdio.h&gt;</span><br /> <br /> <span style="font-family:'Microsoft Yahei';font-size:14px;line-height:28px;background-color:#F5F5F5;">int main()</span><br /> <span style="font-family:'Microsoft Yahei';font-size:14px;line-height:28px;background-color:#F5F5F5;">{</span><br /> <span style="font-family:'Microsoft Yahei';font-size:14px;line-height:28px;background-color:#F5F5F5;">printf("----------");</span><br /> <span style="font-family:'Microsoft Yahei';font-size:14px;line-height:28px;background-color:#F5F5F5;">//假如:本次习题有5道题,则你的输出格式应为printf("AAAAA");</span><br /> <span style="font-family:'Microsoft Yahei';font-size:14px;line-height:28px;background-color:#F5F5F5;">//选项均由大写A,B,C,D组成,输出语句有一条&nbsp;</span><br /> <span style="font-family:'Microsoft Yahei';font-size:14px;line-height:28px;background-color:#F5F5F5;">return 0;</span><br /> <span style="font-family:'Microsoft Yahei';font-size:14px;line-height:28px;background-color:#F5F5F5;">}&nbsp;</span>
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用