版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、循环结构程序设计复习题一选择题1 以下while循环中,循环体执行的次数是:( )k=1;while (-k) k=10; a) 10次 b) 无限次 c) 一次也不执行 d) 1次2 有以下程序段,其中x为整型变量,以下选项中叙述正确的是:( )x=0;while (!x!=0) x+; a) 退出while循环后,x的值为0 b) 退出while循环后,x的值为1 c) while的控制表达式是非法的 d) while循环执行无限次3. 有以下程序段,其中n为整型变量,执行后输出结果是:( ) n=20; while(n-); printf(“%d”,n); a)2 b) 10 c) -1
2、 d) 04. 有以下程序段,其中t为整型变量,以下选项中叙述正确的是:( )t=1;while (-1) t-; if(t) break; a) 循环一次也不执行 b) 循环执行一次 c) 循环控制表达式(-1)不合法 d) 循环执行2次5. 有以下程序段,其中x为整型变量,以下选项中叙述正确的是:( )x=-1;do;while (x+); printf(“x=%d”,x); a) 该循环没有循环体,程序错误 b) 输出x=1 c) 输出x=0 d) 输出x=-16. 有以下程序段,其中x,y为整型变量,程序输出结果是:( ) for(x=0,y=0;(x=1)&(y=1);x+,y-)
3、; printf(“x=%d,y=%d”,x,y); a) x=2,y=0 b) x=1,y=0 c) x=1,y=1 d) x=0,y=0解析:在开始时 x=0,y=0;进入循环判断(x=1)&(y= 1) 条件成立,同时把1赋给y,此时x=0,y=1;然后执行 x+,y-,执行之后x=1,y=0;再进入循环判断(x=1)&(y= 1),条件成立,同时同时把1赋给y,此时x=1,y=1;然后执行 x+,y-,执行之后x=2,y=0;再进入循环判断(x=1)&(y= 1),条件不成立,跳出循环输出x=2,y=0 。7. 有以下程序: main() int x=0,y=0; while(x5&+
4、y) y-,x+; printf(“%d,%d”,y,x);程序的输出结果是:( ) a) 0,5 b) 1,5 c) 0,4 d) 1,48. 有以下程序: main() int num=0; do num+;printf(“%dn”,num); while(num=2);程序的输出结果是:( ) a) 1 b) 1 c) 1 d) 1 2 2 2 3 3 49. 有以下程序: main() int x=3; do printf(“%d”,x-=2); while(!(-x); 程序的输出结果是:( )a) 1 b) 3 0 c) 1 -2 d) 死循环10. 有以下程序: main() i
5、nt y=10; do y-; while(-y); printf(“%dn”,y-);程序的输出结果是:( )a) 1 b) -1 c) 8 d) 011. 有以下程序: main() int x=3,y; do y=-x;if(!y) printf(“x”);else printf(“y”); while(x); 程序的输出结果是:( )a) xyx b) yyx c) yxx d) yxy12. 有以下程序段,此处do-while循环的结束条件是:( )int n=0,p;do scanf(“%d”,&p);n+; while (p!=12345&nb) t=a;a=b;b=t; pri
6、ntf(“%d,%dn”,a,b);程序的输出结果是:( )a) 4,1 b) 1,4 c) 4,-1 d) -1,414. 有以下程序: main() int x=3,y=0; do while(!y) y=-x; while(x-); printf(“%d,%dn”,x,y);程序的输出结果是:( )a) -1,3 b) -1,-3 c) 0,0 d) 1,-315. 有以下程序: main() int m,n; printf(“Enter m,n:”); scanf(“%d%d”,&m,&n); while(m!=n) while(mn) m-=n;while(nm) n-=m; pri
7、ntf(“m=%dn”,m);程序的输出结果是:( )a) m=3 b) m=2 c) m=1 d) m=016. 有以下程序: main() int i,s=1; for(i=1;i=50;i+) if(!(i%5)&!(i%3) s+=i; printf(“%dn”,s);程序的输出结果是:( )a) 409 b) 277 c) 1 d) 9117. 有以下程序: main() int x=0,y=0,i; for(i=1;+i) if(i%2=0) x+;continue;if(i%5=0) y+;break; printf(“%d,%d”,x,y);程序的输出结果是:( )a) 2,1
8、 b) 2,2 c) 2,5 d) 5,218. 有以下程序: main() int i=0,a=0; while(i30)for(;)if(i%10)=0) break;else i-;i+=11; a+=i; printf(“%dn”,a);程序的输出结果是:( )a) 66 b) 63 c) 33 d) 3219. 有以下程序: main() int a,b; for(a=1,b=1;a=10) break;if(b%3=1) b+=3; continue; printf(“%dn”,a);程序的输出结果是:( )a) 101 b) 6 c) 5 d) 420. 有以下程序: main(
9、) int i=0; for(i+=3;i=5;i=i+2) switch(i%5) case 0: printf(“*”);case 1: printf(“#”); break;default: printf(“!”); break;case 2: printf(“&”);程序的输出结果是:( )a) *# b) !& c) !*# d) *#*二填空题1要求使以下程序段输出10个整数,请填空。for(i=0;i=_18_;printf(“%dn”,i+=2);2. 执行下面程序段后,k的值是_0_。r=1; n=203; k=1;do k*=n%10*r; n/=10; r+; while
10、(n);3. 下面程序的输出结果是_ 1 2 5 10_。 main() int i,x=10; for(i=1;i=x;i+) if(x%i=0) printf(“%d ”,i);4. 下面程序的输出结果是_无定值_。 main() int i,sum; for(i=1;i6;i+) sum+=i; printf(“%d”,sum);5. 下面程序的输出结果是_20_。 main() int i,sum=0; for(i=2;i=0;i-) for(j=1;j=i;j+) printf(“*”);for(j=0;j=2-i;j+) printf(“!”);printf(“n”); 7. 下面
11、程序的输出结果是_1,1_。 main() int i,j=0,a=0; for(i=0;i5;i+) do if(j%3) break;a+; j+; while(j0;) if(x%3=0) printf(“%d”,-x); continue; x-; 9. 下面程序的输出结果是_*#_。 main() int i,j=2; for(i=1;i=2*j;i+) switch(i/j) case 0: case 1: printf(“*”); break;case 2: printf(“#”); 三操作题1计算1到10之间的奇数之和以及偶数之和。2输出100以内能被3整除且个位数为6的所有整
12、数。3找出2至99之间的全部同构数。同构数是这样一组数:它出现在其平方数的右边,例如,5是25右边的数,25是625右边的数,5和25都是同构数。4根据以下近似公式求值。 5根据以下公式求S的值。 6根据以下公式求S的值。 技术官员村位于位于亚运城东部,主干道二以东石楼涌以西的地块,占地面积、m2,总建筑面积、m2,共包括地下室南区、地下室北区、地上部分1栋12栋、服务中心、室外工程等多个单体工程。其中住宅面积m2,共12栋,17栋建筑层数为11层,812栋11层(局部复式顶层),首层局部架空,布置公建配套设施。integrated energy, chemicals and textile
13、Yibin city, are the three core pillars of the industry. In 2014, the wuliangye brand value to 73.58 billion yuan, the citys liquor industry slip to stabilise. Promoting deep development of integrated energy, advanced equipment manufacturing industry, changning district, shale gas production capacity
14、 reached 277 million cubic metres, built the countrys first independent high-yield wells and pipelines in the first section, the lead in factory production and supply to the population. 2.1-3 GDP growth figure 2.1-4 Yibin, Yibin city, Yibin city, fiscal revenue growth 2.1.4 topography terrain overal
15、l is Southwest, North-Eastern State. Low mountains and hills in the city landscape as the main ridge-and-Valley, pingba small fragmented nature picture for water and the second land of the seven hills. 236 meters to 2000 meters above sea level in the city, low mountain, 46.6% hills 45.3%, pingba onl
16、y 8.1%. 2.1.5 development of Yibin landscapes and distinctive feature in the center of the city, with limitations, and spatial structure of typical zonal group, 2012-cities in building with an area of about 76.2km2. From city-building situation, old town-the South Bank Center construction is lagging
17、 behind, disintegration of the old city is slow, optimization and upgrading, quality public service resources are still heavily concentrated in the old town together. Southbank Centre has not been formed, functions of the service area space is missing. Meanwhile, peripheral group centres service was
18、 weak and inadequate accounting for city development, suspicious pattern could not be formed. As regards transport, with the outward expansion of cities, cities have been expanding, centripetal city traffic organization has not changed, integrated energy, chemicals and textile Yibin city, are the th
19、ree core pillars of the industry. In 2014, the wuliangye brand value to 73.58 billion yuan, the citys liquor industry slip to stabilise. Promoting deep development of integrated energy, advanced equipment manufacturing industry, changning district, shale gas production capacity reached 277 million c
20、ubic metres, built the countrys first independent high-yield wells and pipelines in the first section, the lead in factory production and supply to the population. 2.1-3 GDP growth figure 2.1-4 Yibin, Yibin city, Yibin city, fiscal revenue growth 2.1.4 topography terrain overall is Southwest, North-
21、Eastern State. Low mountains and hills in the city landscape as the main ridge-and-Valley, pingba small fragmented nature picture for water and the second land of the seven hills. 236 meters to 2000 meters above sea level in the city, low mountain, 46.6% hills 45.3%, pingba only 8.1%. 2.1.5 development of Yibin landscapes and distinctive feature in the center of the city, with limitations, and spatial
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 临时用电施工组织设计
- 2026浙江宁波报业传媒集团有限公司招聘4人考试模拟试题及答案详解
- 新能源汽车充电站市场营销推广计划
- 2026河北保定军幼招聘2人考试模拟试题及答案详解
- 2026年山东省潍坊市住房和城乡建设局人员招聘笔试参考题库及答案详解
- 民用建筑电气施工实施方案
- 煤矿隐患排查治理方案
- 临时用电安全专项施工方案
- 消防安全管理制度
- 施工现场用电应急处置预案
- 2026年山东烟台招远市社区工作者招聘考试试卷-含答案解析
- 2026济南科技创业投资集团有限公司招聘8人考试备考试题及答案详解
- 2025年融通资源开发中层管理干部社会招聘笔试历年参考题库附带答案详解
- 《传染病防治法(2026年修订)》培训试题(含答案)
- 2026年湖北省中小学教师高级职称专业水平能力测试模拟题(含参考答案)
- GB/T 13295-2026水及燃气用球墨铸铁管、管件和附件
- 2026年幼儿园大班毕业典礼照片
- 2026年中国工商银行(河南分行)人员招聘笔试备考题库及答案详解
- 裁剪验片记录表
- 中考物理《电学计算》专项练习题含答案
- PVDF耐腐蚀表优质资料
评论
0/150
提交评论