2024年10月自考04737C++程序设计试题及答案_第1页
2024年10月自考04737C++程序设计试题及答案_第2页
2024年10月自考04737C++程序设计试题及答案_第3页
2024年10月自考04737C++程序设计试题及答案_第4页
2024年10月自考04737C++程序设计试题及答案_第5页
免费预览已结束,剩余4页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

绝密★启用前

2024年10月高等教育自学考试全国统一命题考试

C++程序设计试题答案及评分参考

(课程代码04737)

第一部分选择题

一、单项选择题:本大题共20小题,每小题1分,共20分。

1.D2.B3.A4.D5.D

6.A7.B8.C9.B10.D

11.D12.C13.D14.B15.B

16.A17.D18.C19.B20.D

第二部分非选择题

二、填空题:本大题共10空,每空1分,共10分。

21.f1或f1()

22.Student*sp

23.类名::

24.析构

25.delete

26.重载

27.构造或构造函数

28.多态

29.科学

30.任意类型

三、程序填空题:本大题共5小题,每小题4分,共20分。

31.(1)doublec_s(intr)(2分)

(2)c.c_s(c.r)(2分)

32.(1)this->a=a(2分)

(2)friendvoidPrint(2分)

33.(1)classDerived:publicBase(2分)

(2)"C++等级成绩:"<<s(2分)

34.(1)virtualvoidf2()(2分)

(2)a=&b(2分)

35.(1)template<classT>(2分)

(2)Sample<int>s1(1)(2分)

C++程序设计试题答案及评分参考第1页(共3页)

四、程序分析题:本大题共5小题,每小题6分,共30分。

36.121(3分:每个数据1分)

000(3分:每个数据1分)

37.11(2分:每个数据1分)

22(2分:每个数据1分)

Thenum=2(2分:格式和数据各1分)

38.输出1:10086(3分:格式1分,数据2分)

输出2:88(3分:格式1分,数据2分)

39.A::f1(2分)

C::f2(2分)

C::f1(2分)

40.x=123.46(2分:格式和数据各1分)

str=**123_Hi(2分:格式和数据各1分)

cnt=+3(2分:格式和数据各1分)

五、程序设计题:本大题共2小题,每小题10分,共20分。

41.#include<cstdlib>

usingnamespacestd;

classStudent{

public:

charname[30];

intscore;

}stu[20];

intscoreCompare(constvoid*e1,constvoid*e2)

{

return((*(Student*)e2).score-(*(Student*)e1).score);

}

intmain()

{

ifstreamfin("c:\\score.txt");

ofstreamfout("out.txt");

inti=0;

while(fin>>stu[i].name>>stu[i].score)

{

cout<<stu[i].name<<''<<stu[i].score<<endl;

i++;

}

intn=i;

C++程序设计试题答案及评分参考第2页(共3页)

qsort(stu,n,sizeof(Student),scoreCompare);

for(i=0;i<n;i++)

fout<<stu[i].name<<''<<stu[i].score<<endl;

fin.close();

fout.close();

}

(评分说明:学生数据定义1分,打开文件2分,输出排序前数据2分,排序2分,

写数据1分,关闭文件2分,满分10分)

42.classProduct{

protected:

stringname;

intcount;

doubleprice,total;

public:

Product(){cin>>name>>count>>price;}

voidoutput()

{

cout<<"name:"<<name<<"count:"<<count<<"price"<<price;

cou<<"total:"<<price*count<<endl;

}

};

classWatch:publicProduct{

intyear;

public:

Watch(){cin>>year;}

voidoutput()

{

Product::output();

cout<<"year:"<<year<<endl;

}

};

classBook:publicProduct{

stringz;

public:

Book(){cin>>z;}

voidoutput()

{

Product:

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论