自考(网络教育)c++程序设计语言作业题及解析

自考(网络教育)c++程序设计语言作业题及解析

ID:9321217

大小:32.00 KB

页数:16页

时间:2018-04-27

自考(网络教育)c++程序设计语言作业题及解析_第1页
自考(网络教育)c++程序设计语言作业题及解析_第2页
自考(网络教育)c++程序设计语言作业题及解析_第3页
自考(网络教育)c++程序设计语言作业题及解析_第4页
自考(网络教育)c++程序设计语言作业题及解析_第5页
资源描述:

《自考(网络教育)c++程序设计语言作业题及解析》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、C++程序设计语言一、程序阅读题(本大题共40分,共10小题,每小题4分)1.写出下面程序运行结果。#includevoidmain(){ intx=100,*y,**z; y=&x; z=&y; **z+=100; cout<<"x="<voidmain(){ inti,j,m=3; for(i=0;i<3;i+=2)  for(j=m-1;j>=0;j--)  {   cout<

2、cludevoidf(){ inta=10; staticintb=10; a+=100; b+=100; cout<<"a="<typedefstructstudent{ charname[20]; intscore; voidshow() {  cout<

3、i].score<95)   v[i].score+=5;  else   v[i].score=100;}voidmain(){ STUstu[3]={"Zhangsan",89,"Lisi",97,"Wangwu",59}; incre(stu,3); for(inti=0;i<3;i++)  stu[i].show();}5.写出下面程序运行结果。#includeclassT{public: doublex,y; T(doublea,doubleb) {  x=a;  y=b; } voidshow(doublep) {  cout<

4、voidmain(){ doubleT::*p[2]; Tt(123,456); p[0]=&T::x; p[1]=&T::y; for(inti=0;i<2;i++)  t.show(t.*p[i]);}6.写出下面程序运行结果。#includevoidmain() { intstu1[]={78,98,73,-1},stu2[]={100,98,-1},stu3[]={88,-1},  stu4[]={100,78,33,65,-1},stu5[]={99,88,-1}; int*grad[]={stu1,stu2,stu3,stu4,stu5},**p=gra

5、d,i; for(i=1;i<=5;i++) { cout<<"学生"<=0)  { cout<<**p<<"  ";   (*p)++;  }  p++;  cout<classT{   doubler; doublei;public: T() {  r=0;  i=0; } T(doubler,doublei) {   this->r=r;  this->i=i; } voidshow() {   if(i>=0.0)   cout<

6、ndl;  else   cout<r=this->r+x;  return*this; }};voidmain(){ Tt1(13,-9),t2; t2=t1+100; t2.show();}8.写出下面程序运行结果。#includevoidex(intx){  try {   if(x==0)   throwx;  if(x==1)   throw'c';  if(x==2)   throw123.133; } catch(...) {   cout<<"捕获到一

7、个异常!"<#includeclassT{   char*str;public: T() {   str=newchar(''); } ~T() {   delete[]str; } voidMyputs() {   cout<

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。