欢迎来到天天文库
浏览记录
ID:9321217
大小:32.00 KB
页数:16页
时间:2018-04-27
《自考(网络教育)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=gra5、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<
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=gra5、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<
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=gra5、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<
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<
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<
此文档下载收益归作者所有