C++填空题 及答案

上传人:woxinch****an2018 文档编号:39311053 上传时间:2018-05-14 格式:DOCX 页数:29 大小:23.56KB
返回 下载 相关 举报
C++填空题 及答案_第1页
第1页 / 共29页
C++填空题 及答案_第2页
第2页 / 共29页
C++填空题 及答案_第3页
第3页 / 共29页
C++填空题 及答案_第4页
第4页 / 共29页
C++填空题 及答案_第5页
第5页 / 共29页
点击查看更多>>
资源描述

《C++填空题 及答案》由会员分享,可在线阅读,更多相关《C++填空题 及答案(29页珍藏版)》请在金锄头文库上搜索。

1、/8522.3x 二、填空题(25 道小题,共 34 分)1、C 语言程序执行的入口点是 主函数 main 。2、设 y 是 int 型变量,请写出判断 y 为奇数的关系表达式 y%2!=0 。3、设 x 是 int 型变量,请写出 x 是偶数并且不能被 3 整除的表达式 y%2=0 /或 cout/或 #include #includevoid main( )int max, min,x;x= rand( )%101+100;printf(“%4d“,x);/cout max) max=x ; if(x /或 #include void main()int i,a;for(i=1;ia;if

2、( a%7=0 )printf(“%d“,a); /或 cout10 ) printf(“no exist“);/或 cout /或 #include void main() printf(“The sun=%dn“, SunFun(10) );/或 cout /或 #include double fun(double x,int n)int i; double y=1;for(i=1;iscorei;aver= average(score) ;printf(“the average score is:%f“,aver);/或 cout /或 #include void main() int

3、a44=1,2,3,4,2,2,5,6,3,5,3,7,4,6,7,4;int i,j,found=1;for(i=0;iaji)k=j;s+= aki ;*sum =s;void main() int xMN=3,2,5,1,4,1,8,3,s;SumColumMin( x, printf(“%dn“,s); /或 coutmax ) min=max;return min;26、C 语言程序设计包括编写源代码、 编辑、编译 、连接和运行等步骤。27、C 语言中唯一的三目运算符是 条件运算符 ? : 。28、有一个函数原型如下所示:abc(float x,float y);则该函数的返回类型为

4、 int 。29、在 C 语言中,形参的缺省存储类是 auto 。30、设 int a23=5,6; 则数组元素 a00 的值为 5。31、若有定义 int a451,2,3,3,2,1,6,1;则二维数组 a 中元素a22的值是 0 。32、已知有以下的说明,int a=8,1,2,5,0,4,7,6,3,9;那么 a*(a+a3)的值为 0 。33、下面程序输出 1 至 100 之间每位数的乘积小于每位数的和的数。#include /或 #include main()int n,k=1,s=0,m;for(n=1;n10 p= a=*p+b; 执行该程序段后,a 的值为 11 。45、斐波

5、那契数列中的头两个数是 0 和 1,从第三个数开始,每个数等于前两个数的和,即:0,1,1,2,3,5,8,13,21,.等。下面这个程序就是求斐波哪契数列的前 20 个数。请填空。#include /或 #include void main()int f,f1,f2,i;f1=0;f2=1;printf(“%dn%dn“,f1,f2); /或 cout /或 #include void main()int n,i,j,k;n=0;for(i=1;i /或 #include int fun(int x)int s=0,i;for(int i=2;in;printf(“%d 的所有因子(不包括

6、1 与自身)之和是%d“, fun(n) );/或 cout /或 #include void main() int i,s,k,count=0;for(i=100;i /或 #include main()int i,j;for(i=0; iai; scanf(“%d“,/cinm;no=search( a, m );if( no!=-1 )printf(“found!%d“,no+1);/cout /或 #include void main()Float x,amax,amin ;scanf(“%f“, /或 cinx;amax=x;amin=x;while( x=0 )if(xamax)a

7、max=x;if( xx;printf(“amax=%f, amin=%fn“, amax, amin);/或 cout /或 #include void main()int A,B,C,D;int x,y,z;for(A=1;Aab;if(ba)int t;t=a; a=b; b=t; 其中 t 的作用域称作 复合语句(分程序、程序块) 。78、以下程序从读入的整数数据中,统计大于零的整数个数和小于零的整数个数.用输入零来结束输入,程序中用变量 i 统计大于零的整数个数,用变量 j 统计小于零的整数个数.请填空.#include /或 #include / #include main()int n,i,j;printf(“输入非零的整数(输入零结束程序)“); /或 coutn;while ( n!=0 ) if(n0) i= i+1 ;if(nnprintf(“i=%4d j=%4dn“,i,j);/或 cout“i=“setw(4)i“ j=“setw(4)jendl;79、以下循环体的执行次数是 1 。main() int i,j; for(i=0,j=1; i=j+1; i+=2, j-)printf(“%d n“,i); 80、若有声明语句 char * pCh;则系统为变量 pCh 分配的内存单元字节数是 4 个。

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号