版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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浙江温州市瑞安市社会治理中心编外人员招聘1人备考题库带答案详解(新)
- 2026浙江嘉兴市海宁市青少年宫公益性岗位招聘2人备考题库及参考答案详解1套
- 2026甘肃定西临洮县文庙巷社区卫生服务中心招聘卫生专业技术人员5人备考题库含答案详解(夺分金卷)
- 2026湖北恩施州宣恩县万德昌智能机器人有限公司招聘1人备考题库及参考答案详解1套
- 2026福建莆田第三中学代课教师招聘4人备考题库附参考答案详解(满分必刷)
- 2026年中央加湿系统项目可行性研究报告
- 2026浙江嘉兴高级中学编外用工招聘2人备考题库带答案详解(培优b卷)
- 2026福建厦门市集美区新亭幼儿园非在编教职工招聘1人备考题库含答案详解(突破训练)
- 2026福建泉州丰泽区东湖实验幼儿园招聘备考题库及1套完整答案详解
- 2026贵州毕节市纳雍县文体广电旅游局文化人才志愿者招募30人备考题库及一套参考答案详解
- 水晶科普内容
- 2025年人才招聘市场智能招聘平台实施方案
- 2025上海智能机器人百大场景案例集
- 年产10万吨丁二烯氰化法制己二睛绿色生产工艺的设计
- 风信子教学课件
- 撤销限高和失信申请书
- 2025年羽毛球馆场地租赁
- 天津市历史高考考试范围知识点总结
- GRR测量系统分析报告范例
- 第四章连锁及交换定律1
- 广告加工制作报价单
评论
0/150
提交评论