欢迎来到天天文库
浏览记录
ID:43460408
大小:72.01 KB
页数:10页
时间:2019-10-03
《计算机2级C++试题(附答案)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、试卷一一、理论题(20分,每小题1分)(1)【单选题】下面程序的输出结果是_________。#includefun(intx){intp;if(x==0
2、
3、x==1)return(3);p=x-fun(x-2);returnp;}voidmain(){cout<voidmain(){floatx,y
4、;cin>>x;if(x<0.0)y=0.0;elseif((x<10.0)&&(x!=2.0))y=1.0/(x+2.0);elseif(x<5.0)y=1.0/x;elsey=5.0;cout<voidmain(){char*p[]={"mop","
5、book","w","sp"};inti;for(i=3;i>=0;i--,i--)cout<<*p[i];cout<6、限多次B)8C)6D)2参考答案:C(7)【单选题】下面程序的输出结果是_________。#includevoidmain(){intx[]={2,4,6,8},i;int*p=x;for(i=0;i<4;i++)x[i]=*p++;cout<7、door并回车,则输出结果是_________。charfun(char*c){if(*c<='z'&&*c>='a')*c-='a'-'A';return*c;}voidmain(){chars[81],*p=s;gets(s);while(*p){*p=fun(p);putchar(*p);p++;}putchar('');}A)openthedoorB)OPENTHEDOORC)OpenthedoorD)oPENTHEDOOR参考答案:B(10)【单选题】若有以下程序段,则变量v的值是_________。in8、tm=1,n=2,v;v=m/n;A)0B)1/2C)0.5D)1参考答案:A(11)【单选题】若m和n都是整型变量,且m=3,n=5,则以下语句输出的结果是_________。cout<<(m+=n,n)<#definesub(x,y)(x)*x+yvoidmain(){inta=3,b=4;cout<9、6B)13C)21D)20参考答案:B(13)【单选题】下面程序的输出结果是_________。#includevoidmain(){intnum=1;while(num<=2){num++;cout<voidmain(){intx=0,y=1,a=0,b=0;switch(x){case0:switch(y){case0:a++;break10、;case1:b++;break;}case1:a++;b++;break;}cout<
6、限多次B)8C)6D)2参考答案:C(7)【单选题】下面程序的输出结果是_________。#includevoidmain(){intx[]={2,4,6,8},i;int*p=x;for(i=0;i<4;i++)x[i]=*p++;cout<7、door并回车,则输出结果是_________。charfun(char*c){if(*c<='z'&&*c>='a')*c-='a'-'A';return*c;}voidmain(){chars[81],*p=s;gets(s);while(*p){*p=fun(p);putchar(*p);p++;}putchar('');}A)openthedoorB)OPENTHEDOORC)OpenthedoorD)oPENTHEDOOR参考答案:B(10)【单选题】若有以下程序段,则变量v的值是_________。in8、tm=1,n=2,v;v=m/n;A)0B)1/2C)0.5D)1参考答案:A(11)【单选题】若m和n都是整型变量,且m=3,n=5,则以下语句输出的结果是_________。cout<<(m+=n,n)<#definesub(x,y)(x)*x+yvoidmain(){inta=3,b=4;cout<9、6B)13C)21D)20参考答案:B(13)【单选题】下面程序的输出结果是_________。#includevoidmain(){intnum=1;while(num<=2){num++;cout<voidmain(){intx=0,y=1,a=0,b=0;switch(x){case0:switch(y){case0:a++;break10、;case1:b++;break;}case1:a++;b++;break;}cout<
7、door并回车,则输出结果是_________。charfun(char*c){if(*c<='z'&&*c>='a')*c-='a'-'A';return*c;}voidmain(){chars[81],*p=s;gets(s);while(*p){*p=fun(p);putchar(*p);p++;}putchar('');}A)openthedoorB)OPENTHEDOORC)OpenthedoorD)oPENTHEDOOR参考答案:B(10)【单选题】若有以下程序段,则变量v的值是_________。in
8、tm=1,n=2,v;v=m/n;A)0B)1/2C)0.5D)1参考答案:A(11)【单选题】若m和n都是整型变量,且m=3,n=5,则以下语句输出的结果是_________。cout<<(m+=n,n)<#definesub(x,y)(x)*x+yvoidmain(){inta=3,b=4;cout<9、6B)13C)21D)20参考答案:B(13)【单选题】下面程序的输出结果是_________。#includevoidmain(){intnum=1;while(num<=2){num++;cout<voidmain(){intx=0,y=1,a=0,b=0;switch(x){case0:switch(y){case0:a++;break10、;case1:b++;break;}case1:a++;b++;break;}cout<
9、6B)13C)21D)20参考答案:B(13)【单选题】下面程序的输出结果是_________。#includevoidmain(){intnum=1;while(num<=2){num++;cout<voidmain(){intx=0,y=1,a=0,b=0;switch(x){case0:switch(y){case0:a++;break
10、;case1:b++;break;}case1:a++;b++;break;}cout<
此文档下载收益归作者所有