第一范文网 - 专业文章范例文档资料分享平台

全国2011年10月自学考试C加加程序设计试题和答案

来源:用户分享 时间:2025/7/6 20:50:29 本文由闁哄鏅炴慨銈夊焻閿燂拷 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

http://www.zikao5.com 我自考网整理

a. f1(1.6,3.8) ; p=&a; p. get( ) ; }

45. #include < iostream. h > class point{ int x;

public: void init ( int a) { x = a; }

int getx( ){ return x;} void setx ( int a) { x = a; } };

void main( ){ point a; a. init (20,30) ;

cout << a. getx( ) << endl; }

四、完成程序题(本大题共5小题,每小题4分,共20分) 46.完成下面类中成员函数的定义。

class test { private: int nl ; float fl; public:

test(int,float f); test(test&); };

test::test( ________ ) {nl=n; fl=f;} test:: test(test&t) {nl=t.nl; fl=________;}

47.在下面程序中的下划线处填上适当的语句,使程序的输出结果如下:

11,77 11,77

http://www.zikao5.com 我自考网整理

源程序如下: #include using namespace std; class base { private: int x,y; public:

void initxy(int a,int b){x=a;y=b;} void show() {________} } ; void main() {

base a,b; __________ a.show(); b=a; b.show(); }

48.在下面程序中的下划线处填上适当的程序,使程序的输出结果如下:

x=1,y=2 x=30,y=40 源程序如下: #include class Sample { int x,y; public:

Sample(){x=y=0;}

Sample(int i,int j){x=i;y=j;} void copy(Sample & s);

void setxy(int i,int j){x=i;y=j;}

void print(){cout<<\,y=\;} };

void Sample::copy (________)

http://www.zikao5.com 我自考网整理

{

x=s.x;y=s.y; }

void func(________) ) {

s1.setxy(10,20); s2.setxy(30,40); }

void main() {

Sample p(1,2),q; q.copy(p); func(p,q); p.print(); q.print(); } Sample&s }

49.在下面程序的下划线处填上正确的语句,使其得到下面的输出结果。

20 21 22 a[0]=20 a[1]=21 a[2]=22 程序清单如下: #include < iostream > using namespace std; class base {

private:int x; public:

void setx(int a){x=a;}

http://www.zikao5.com 我自考网整理

int getx(){return x;} } ; void main() {

base a [3],*p; a[0].setx(20); a[1].setx(21); a[2].setx(22); for(p=a; p

50.在下面程序中的下划线处填上适当的程序,使程序的输出结果如下:

x=2,y=3 源程序如下: #include class Sample { int x,y; public:

Sample(){x=y=0;}

Sample(________){x=a;y=b;} void disp() {

cout<<\,y=\; } } ; void main() {

Sample s(2,3),________ P - >disp(); }

五、程序分析题(本大题共2小题,每小题5分,共10分) 51.请给出下面程序的输出结果

#include

全国2011年10月自学考试C加加程序设计试题和答案.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c2khlt3ubem0cqsi0v4z6_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top