2017中央电大《C++程序设计A》期末考试完整版小抄(可排版)

上传人:韩旗 文档编号:24870989 上传时间:2017-12-08 格式:DOC 页数:48 大小:967.69KB
返回 下载 相关 举报
2017中央电大《C++程序设计A》期末考试完整版小抄(可排版)_第1页
第1页 / 共48页
2017中央电大《C++程序设计A》期末考试完整版小抄(可排版)_第2页
第2页 / 共48页
2017中央电大《C++程序设计A》期末考试完整版小抄(可排版)_第3页
第3页 / 共48页
2017中央电大《C++程序设计A》期末考试完整版小抄(可排版)_第4页
第4页 / 共48页
2017中央电大《C++程序设计A》期末考试完整版小抄(可排版)_第5页
第5页 / 共48页
点击查看更多>>
资源描述

《2017中央电大《C++程序设计A》期末考试完整版小抄(可排版)》由会员分享,可在线阅读,更多相关《2017中央电大《C++程序设计A》期末考试完整版小抄(可排版)(48页珍藏版)》请在金锄头文库上搜索。

1、2017 中央电大C+程序设计 A期末考试完整版小抄( 可排版)一、单选题1在每个 C 语言程序中都必 须包含有这样一个函数, 该函数的函数名为()。 A. main 2每个 C 语言程序文件的编译错误分为()类。B. 2 3. 字符串a+b=12n 的长度为()。B. 7 4. 在 switch 语句的每个 case 块中,假定都是以 break 语句结束的,则此 switch 语句容易被改写为() 语句。B. if5. 在下面的 do-while 循环语句中,其循环体语句被执行的次数为()。int i=0; do i+; while(i0 & x10 23. 当处理特定问题时的循环次数已知

2、时,通常采用()循环来解决。 A. for 24. 假定 i 的初值为 0,则 在循环语句“while(ib | b=5 的相反表达式为 a5) 的相反表达式为 (x!=0 | y5 的相反表达式为_ x+yname 等价的访问表达式为_(*p).name _。三、写出下列每个程序运行后的输出结果1. #includevoid main()int x=5;switch(2*x-1) case 4: printf(%d ,x); break;case 7: printf(%d ,2*x); break;case 10: printf(%d ,3*x); break;default: printf

3、(%s ,default);printf(%sn,switch end.);default switch end.2. #includevoid main() int f1,f2,i;f1=1;printf(%d ,f1);for(i=2;ivoid main() int a10=12,39,26,41,55,63,72,40,83,95;int i, i1=0, i2=0;for(i=0;i#includevoid main( ) char s15=567891234;int i, n=strlen(s) ;for(i=0; iint LB(int *a, int n) int i,s=1;

4、for(i=0;ivoid main() int i,s=0;for(i=1;i#define N 6void main()int i,aN=2,5,8,10,15,21;for(i=0; i#includevoid main() int i;unsigned int len;char* a5=student,worker,cadre,soldier,zzeasan123;len=strlen(a0);for(i=1; ilen) len=strlen(ai);printf(%dn,len);109. #includevoid main()int a,b;for(a=2,b=3; bvoid

5、LE(int* a, int* b) int x=*a;*a=*b; *b=x;void main() int x=15, y=26;printf(%d %dn,x,y);LE( 15 2626 1511. #includevoid main() int i, s=0;for(i=1;i+) if(s30) break;if(i%2=0) s+=i;printf(s=%dn,s);s=4212. #includevoid main() int a9=36,25,48,24,55,40,18,66,20;int i, b1, b2;b1=b2=a0;for(i=1; ib1) b1=ai;if(

6、aivoid SB(char ch) switch(ch) case A: case a:printf(WW ); break;case B: case b:printf(GG ); break;default:printf(BB ); break; void main() char a1=a,a2=B,a3=f;SB(a1);SB(a2);SB(a3);printf(n);WW GG BB14. #include#define M 6void main()int i,x;int aM=10,15,22,37,46,58;for(i=0; istruct Worker char name15;

7、 int age; float pay;void main() struct Worker x=wanghua,52,2350;struct Worker y, *p;y=x; p=104 2370.0016. #includevoid main() int i,j,k=0;for(i=0; ivoid main() int x=60;int i=2, p=1;while(1) if(x%i=0) p*=i; x/=i;if(ivoid main() int a8=76,63,54,62,40,75,90,58;int i;for(i=0; i70) printf(%d ,ai);printf

8、(n);76 75 9019. #includevoid WF(int x, int y) x=x+y;y+=x;printf(%d %dn,x,y);void main() int x=3, y=8;WF(x,y);11 19 20. #includeint LA(int *a, int n) int i,s=0;for(i=0;iint SG(int x) /x 为大于等于 2 的整数int a=(int)sqrt(x);/sqrt(x)取 x 的平方根int i=2;while(idata;f=f-next;while(f) if(f-datax) x=f-data;f=f-next;r

9、eturn x;假定 struct IntNode 的类型定义为:struct IntNode int data; struct IntNode* next;3. #includeint SA(int a, int b) if(ab) return 1;else if(a=b) return 0;else return -1;4. void Output(struct IntNode *f) /f 为单链表的表头指针if(!f) return;while(f) printf(%d ,f-data);f=f-next;printf(n);假定 struct IntNode 的类型定义为:stru

10、ct IntNode int data; struct IntNode* next;5. int SC(int a, int b, int c) if(a=b if(b=a return c;6. int* LI(int n) int* a=malloc(n*sizeof(int);int i;for(i=0;i=k) c+;return c; 8. void QA(struct Worker a, int n) int i;for(i=0; ib 则返回 1,若 a=b 则返回 0,若 a void main()int i; for(i=3; i int n,i=1; double sum=

11、0; void main()scanf(%d, while(ivoid main()int i; int p=1; int s=1;for(i=1;ix1) x1=ai; if(ai0 & x10Bx10Cx0 & x109字符串“a+b=12n”的长度为(B)。A6B7C8 D910在下列符号常量定义中。错误的定义语句格式为(C)。Aconst M1=10; Bconst int M2=20;Cconst M3 10 Dconst char mark=3;11带有随机函数的表达式 rand()%20的值在(C)区间内,A119B120C019 D02012当处理特定问题时的循环次数已知时,通

12、常采用(A)循环来解决。AforBwhileCdo-while Dswitch13在 switch 语句的每个 case 块中,假定都是以 break 语句结束的,则此 switch 语句容易被改写为(B)语句。AforBifCdo Dwhile14for 语句能够被改写为(D)语句。A复合 BifCswitch Dwhile15下面循环语句执行结束后输出的 i 值为(B )。for(int i=0;in/2)cout5的相反表达式为_x+yb | b=5的相反表达式为_a5 | by 逻辑值为_false_。35若 x=5,y=10,则 xb)_7与结构成员访问表达式(*fp).score

13、等价的表达式是_fp-score_。三、写出下列每个程序运行后的输出结果1. #includevoid main()int x=5;switch(2*x-3)case 4:printf(%d ,x);case 7:printf(%d ,2*x+1);case 10:printf(%d ,3*x-1);break;default:printf(%s ,defaultn);printf(%sn,switch end.); 输出结果为:11 14 switch end.Press any key to continue2. #includevoid main()int i,s=0;for(i=1;i

14、void main()int i,s1=0,s2=0;for(i=0;ivoid main()int n=10,y=1;while(n-)y+;y+;printf(y=%dn,y);输出结果为:y=21.Press any key to continue5. #includevoid main()int f,f1,f2,i;f1=f2=1;printf(%d %d ,f1,f2);for(i=3;i#includevoid main()int i,n;for(n=2;ntemp)printf(%d ,n);printf(n);输出结果为:2 3 5 7 11 13 17 19Press any

15、 key to continue7. #include#includeconst int M=20;void main()int i,c2,c3,c5;c2=c3=c5=0;for(i=1;i#includeconst int M=20;void main() int i,s;for(i=1,s=0;ivoid main()int a10=12,39,26,41,55,63,72,40,83,95;int i,i1=0,i2=0;for(i=0;i#includevoid main()int i;char *a5=student,worker,cadre,soldier,peasant;char *p1,*p2;p1=p2=a0;for(i=0;i0)p1=ai;if(strcmp(ai,p2)int a10=4,5,

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

当前位置:首页 > 资格认证/考试 > 成考

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