2024年10月自考04737C++程序設(shè)計試題及答案_第1頁
2024年10月自考04737C++程序設(shè)計試題及答案_第2頁
2024年10月自考04737C++程序設(shè)計試題及答案_第3頁
2024年10月自考04737C++程序設(shè)計試題及答案_第4頁
2024年10月自考04737C++程序設(shè)計試題及答案_第5頁
免費預(yù)覽已結(jié)束,剩余4頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

絕密★啟用前

2024年10月高等教育自學(xué)考試全國統(tǒng)一命題考試

C++程序設(shè)計試題答案及評分參考

(課程代碼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.析構(gòu)

25.delete

26.重載

27.構(gòu)造或構(gòu)造函數(shù)

28.多態(tài)

29.科學(xué)

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++程序設(shè)計試題答案及評分參考第1頁(共3頁)

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

36.121(3分:每個數(shù)據(jù)1分)

000(3分:每個數(shù)據(jù)1分)

37.11(2分:每個數(shù)據(jù)1分)

22(2分:每個數(shù)據(jù)1分)

Thenum=2(2分:格式和數(shù)據(jù)各1分)

38.輸出1:10086(3分:格式1分,數(shù)據(jù)2分)

輸出2:88(3分:格式1分,數(shù)據(jù)2分)

39.A::f1(2分)

C::f2(2分)

C::f1(2分)

40.x=123.46(2分:格式和數(shù)據(jù)各1分)

str=**123_Hi(2分:格式和數(shù)據(jù)各1分)

cnt=+3(2分:格式和數(shù)據(jù)各1分)

五、程序設(shè)計題:本大題共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++程序設(shè)計試題答案及評分參考第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();

}

(評分說明:學(xué)生數(shù)據(jù)定義1分,打開文件2分,輸出排序前數(shù)據(jù)2分,排序2分,

寫數(shù)據(jù)1分,關(guān)閉文件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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論