2019电大c++语言程序设计课程的程序分析练习题及答案资料必考重点【电大考试必备

上传人:优*** 文档编号:72157498 上传时间:2019-01-22 格式:DOC 页数:20 大小:91.50KB
返回 下载 相关 举报
2019电大c++语言程序设计课程的程序分析练习题及答案资料必考重点【电大考试必备_第1页
第1页 / 共20页
2019电大c++语言程序设计课程的程序分析练习题及答案资料必考重点【电大考试必备_第2页
第2页 / 共20页
2019电大c++语言程序设计课程的程序分析练习题及答案资料必考重点【电大考试必备_第3页
第3页 / 共20页
2019电大c++语言程序设计课程的程序分析练习题及答案资料必考重点【电大考试必备_第4页
第4页 / 共20页
2019电大c++语言程序设计课程的程序分析练习题及答案资料必考重点【电大考试必备_第5页
第5页 / 共20页
点击查看更多>>
资源描述

《2019电大c++语言程序设计课程的程序分析练习题及答案资料必考重点【电大考试必备》由会员分享,可在线阅读,更多相关《2019电大c++语言程序设计课程的程序分析练习题及答案资料必考重点【电大考试必备(20页珍藏版)》请在金锄头文库上搜索。

1、电大C+语言程序设计课程的程序分析练习题徐孝凯 一、写出下列每个程序运行后的输出结果 1. #include #include void main() int x=20, y=6, z; char op=+; switch(op) case +: z=x+y; break; case -: z=x-y; break; default: cout操作符op出错,退出运行!;exit(1); cout”z=”zendl; 运行结果: 2. #include #include void main() char* a5=student,worker,cadre,soldier,apen; unsign

2、ed int n=strlen(a0); /求字符串a0的长度 for(int i=1;in) n=strlen(ai); coutnendl; 运行结果: 3. #include int WF(int x, int y) x=x+y; y=x+y; return x+y; void main() coutWF(8,5)endl; 运行结果: 4. #include const int N=9; void main() int aN=2,4,6,8,10,12,14,16,18; int s=0; for(int i=0; iN; i+) if(ai%3=0) s+=ai; cout”s=”s

3、endl; 运行结果: 5. #include void main() int* d=new int5; int i,s=0; for(i=0;i5;i+) di=2*i+1; for(i=0;i5;i+) s+=di; cout3*sendl; deleted; 6. #include void SB(char ch) switch(ch) case A: case a: cout优! ; break; case B: case b: cout良! ; break; case C: case c: cout通过! ; break; default: cout不通过!;break; void

4、main() SB(A); SB(c); coutendl; 运行结果: 7. #include void main() int a6=36,25,48,14,55,40; int x=a0; for(int i=1;ix) x=ai; cout”x=”xendl; 运行结果: 8. #include void main() int a6=32,53,27,19,12,45; for(int *p=a; pa+6; p+) if(*p%3=0) cout*p ; coutendl; 运行结果: 9. #include int* LG(int m) int* a=new int(m+5); re

5、turn a; void main() int n1=12; int *b=LG(n1); cout*bendl; delete b; 运行结果: 10. #include #include struct Worker char name15; int age; float pay; ; void main() Worker x; strcpy(x.name, WeiRong); x.age=45; x.pay=3275; coutx.name x.age x.payendl; 运行结果: 11. #include void main() int n=5, sum=0; while(n) su

6、m+=n; n-; cout”sum=”sumendl; 运行结果: 12. #include const int N=6; void main() int aN=76,83,54,62,40,65; int c1, c2; c1=c2=a0; for(int i=1;ic1) c1=ai; else if(aic2) c2=ai; coutc1 c2endl; 运行结果: 13. #include void main() int a8=4,8,15,16,20,30,48,62; int *p=a; while(pa+8) cout*p ; p+=3; coutendl; 运行结果: 14.

7、#include int LF(int x, int y) x=x+y; y=x+y; return x+y; void main() int x=5, y=8; coutLF(1,2) LF(3,4)endl; 运行结果: 15. #include class A int a,b; public: A() a=b=0; A(int aa, int bb) a=aa; b=bb; couta bendl; ; void main() A x,y(3,4); 运行结果: 16. #include void main() int n=4,y=1; while(n-) y*=3; couty=yendl; 运行结果: 17. #include void main() int a8=2,8,10,5,12,7,9,20; int c=0, i=0; while(i10) c+; i+; coutc=cendl; 运行结果: 18. #include void main() int a5=3,6,9,12,8; for(int *p=a; p8) cou

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


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

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