電大C++語言程序設(shè)計期末考試試題及答案小抄參考
《電大C++語言程序設(shè)計期末考試試題及答案小抄參考》由會員分享,可在線閱讀,更多相關(guān)《電大C++語言程序設(shè)計期末考試試題及答案小抄參考(12頁珍藏版)》請在裝配圖網(wǎng)上搜索。
1、專業(yè)好文檔 C++語言程序設(shè)計 期末考試試題及答案 姓名 ____________ 學(xué)號 ____________ 班號 ___________ 題 號 一 二(1) 二(2) 三 總 分 成 績 一、填空 1.在類中必須聲明成員函數(shù)的 原型 ,成員函數(shù)的 實(shí)現(xiàn) 部分可以寫在類外。 2.如果需要在被調(diào)函數(shù)運(yùn)行期間,改變主調(diào)函數(shù)中實(shí)參變量的值,則函數(shù)的形參應(yīng)該是 引用 類型或 指針 類型。 3. 抽象 類只能作為基類使用,而不能聲明它的對象。 4
2、.進(jìn)行函數(shù)重載時,被重載的同名函數(shù)如果都沒有用const修飾,則它們的形參 個數(shù) 或 類型 必須不同。 5.通過一個 常 對象只能調(diào)用它的常成員函數(shù),不能調(diào)用其他成員函數(shù)。 6.函數(shù)的遞歸調(diào)用是指函數(shù)直接或間接地調(diào)用 自身 。 7.拷貝構(gòu)造函數(shù)的形參必須是 本類對象的引用 。 二、閱讀下列程序,寫出其運(yùn)行時的輸出結(jié)果 如果程序運(yùn)行時會出現(xiàn)錯誤,請簡要描述錯誤原因。 1.請在以下兩題中任選一題,該題得分即為本小題得分。如兩題都答,則取兩題得分之平均值為本小題得分。 (1)程序: - 12 - #include
3、 4、ic:
Derived1(int m=1):
Base("Base",m-1)
{ n=m; }
void output(void)
{ cout< 5、 }
};
int main()
{
Base B("Base Class",1);
Derived2 D;
B.output();
D.output();
}
運(yùn)行結(jié)果:
1
Base Class
2
1
0
Base
(2)程序:
#include 6、;}
protected:
int i;
int j;
};
int main()
{
Samp *p;
p=new Samp[5];
if(!p)
{ cout<<"Allocation error\n";
return 1;
}
for(int j=0;j<5;j++)
p[j].Setij(j,j);
for(int k=0;k<5;k++)
cout<<"Muti["< 7、
Muti[0] is:0
Muti[1] is:1
Muti[2] is:4
Muti[3] is:9
Muti[4] is:16
Destroying..4
Destroying..3
Destroying..2
Destroying..1
Destroying..0
2.請在以下兩題中任選一題,該題得分即為本小題得分。如兩題都答,則取兩題得分之平均值為本小題得分。
(1)程序:
#include 8、=100);
int& Elem(int ndx);
void Display(void);
void Set(void);
~Vector(void);
protected:
int size;
int *buffer;
};
Vector::Vector(int s)
{
buffer=new int[size=s];
}
int& Vector::Elem(int ndx)
{
if(ndx<0||ndx>=size)
{
cout<<"error in index"< 9、l;
exit(1);
}
return buffer[ndx];
}
void Vector::Display(void)
{
for(int j=0; j 10、b(a);
a.Set();
b.Display();
}
運(yùn)行結(jié)果:
1
2
3
4
5
6
7
8
9
10
最后出現(xiàn)錯誤信息,原因是:聲明對象b是進(jìn)行的是淺拷貝,b與a共用同一個buffer,程序結(jié)束前調(diào)用析構(gòu)函數(shù)時對同一內(nèi)存區(qū)進(jìn)行了兩次釋放。
(2)程序:
#include 11、etAge( int age )
{ *itsAge=age; }
protected:
int * itsAge;
};
CAT::CAT()
{
itsAge=new int;
*itsAge=5;
}
CAT::~CAT()
{
delete itsAge;
itsAge=NULL;
}
int main()
{
CAT a;
cout<<"as age:"< 12、out<<"bs age:"< 13、 程序功能說明:從鍵盤讀入兩個分別按由小到大次序排列的整數(shù)序列,每個序列10個整數(shù),整數(shù)間以空白符分隔。用這兩個序列分別構(gòu)造兩個單鏈表,每個鏈表有10個結(jié)點(diǎn),結(jié)點(diǎn)的數(shù)據(jù)分別按由小到大次序排列。然后將兩個鏈表合成為一個新的鏈表,新鏈表的結(jié)點(diǎn)數(shù)據(jù)仍然按由小到大次序排列。最后按次序輸出合并后新鏈表各結(jié)點(diǎn)的數(shù)據(jù)。
程序運(yùn)行結(jié)果如下,帶下劃線部分表示輸入內(nèi)容,其余是輸出內(nèi)容:
1 3 5 7 9 11 13 15 17 19
2 4 6 8 10 12 14 16 18 20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
14、#include 15、 Node 16、int position; // 當(dāng)前元素在表中的位置序號。由函數(shù)Reset使用
Node 17、 //(假設(shè)當(dāng)前表為空)。被拷貝構(gòu)造函數(shù)、operator=調(diào)用
public:
LinkedList(void); // 構(gòu)造函數(shù)
LinkedList(const LinkedList 18、 int ListEmpty(void) const; //size為0時返回TRUE,否則返回FALSE
void Reset(int pos = 0); //將指針currPtr移動到序號為pos的節(jié)點(diǎn),
//prevPtr相應(yīng)移動,position記錄當(dāng)前節(jié)點(diǎn)的序號
void Next(void); //使prevPtr和currPtr移動到下一個節(jié)點(diǎn)
int EndOfList(void) const; // currPtr等于NULL時返回TRUE, 否則返回FA 19、LSE
int CurrentPosition(void) const; //返回數(shù)據(jù)成員position
void InsertFront(const T& item); //在表頭插入一個數(shù)據(jù)域?yàn)閕tem的節(jié)點(diǎn)
void InsertRear(const T& item); //在表尾添加一個數(shù)據(jù)域?yàn)閕tem的節(jié)點(diǎn)
void InsertAt(const T& item); //在當(dāng)前節(jié)點(diǎn)之前插入一個數(shù)據(jù)域?yàn)閕tem的節(jié)點(diǎn)
void InsertAfter(const T& item); //在當(dāng)前節(jié)點(diǎn)之后插入 20、一個數(shù)據(jù)域?yàn)閕tem的節(jié)點(diǎn)
T DeleteFront(void); //刪除頭節(jié)點(diǎn),釋放節(jié)點(diǎn)空間,更新prevPtr、currPtr和size
void DeleteAt(void); //刪除當(dāng)前節(jié)點(diǎn),釋放節(jié)點(diǎn)空間,更新prevPtr、currPtr和size
T& Data(void); // 返回對當(dāng)前節(jié)點(diǎn)成員data的引用
void ClearList(void); // 清空鏈表:釋放所有節(jié)點(diǎn)的內(nèi)存空間。
};
//類實(shí)現(xiàn)部分略......
template 21、t(LinkedList 22、 { lc->InsertRear(lb->Data());
lb->DeleteAt();
}
}
while ( !la->ListEmpty() )
{
lc->InsertRear(la->Data());
la->DeleteAt();
}
while ( !lb->ListEmpty() )
{
lc->InsertRear(lb->Data());
lb->DeleteAt();
}
23、
}
int main()
{
LinkedList 24、
lb.Reset();
MergeList(&la, &lb, &lc);//合并鏈表
lc.Reset();
// 輸出各節(jié)點(diǎn)數(shù)據(jù),直到鏈表尾
while(!lc.EndOfList())
{
cout < 25、ed the courage to do it."
His comments came hours after Fifa vice-president Jeffrey Webb - also in London for the FAs celebrations - said he wanted to meet Ivory Coast international Toure to discuss his complaint.
CSKA general director Roman Babaev says the matter has been "exaggerated" by the Iv 26、orian and the British media.
Blatter, 77, said: "It has been decided by the Fifa congress that it is a nonsense for racism to be dealt with with fines. You can always find money from somebody to pay them.
"It is a nonsense to have matches played without spectators because it is against the spirit 27、of football and against the visiting team. It is all nonsense.
"We can do something better to fight racism and discrimination.
"This is one of the villains we have today in our game. But it is only with harsh sanctions that racism and discrimination can be washed out of football."
The (lack of) a 28、ir up there
Watch mCayman Islands-based Webb, the head of Fifas anti-racism taskforce, is in London for the Football Associations 150th anniversary celebrations and will attend Citys Premier League match at Chelsea on Sunday.
"I am going to be at the match tomorrow and I have asked to meet 29、Yaya Toure," he told BBC Sport.
"For me its about how he felt and I would like to speak to him first to find out what his experience was."
Uefa hasopened disciplinary proceedings against CSKAfor the "racist behaviour of their fans" duringCitys 2-1 win.
Michel Platini, president of European footba 30、lls governing body, has also ordered an immediate investigation into the referees actions.
CSKA said they were "surprised and disappointed" by Toures complaint. In a statement the Russian side added: "We found no racist insults from fans of CSKA."
Baumgartner the disappointing news: Mission aborte 31、d.
The supersonic descent could happen as early as Sunda.
The weather plays an important role in this mission. Starting at the ground, conditions have to be very calm -- winds less than 2 mph, with no precipitation or humidity and limited cloud cover. The balloon, with capsule attached, will move 32、through the lower level of the atmosphere (the troposphere) where our day-to-day weather lives. It will climb higher than the tip of Mount Everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratospher 33、e. As he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.
The balloon will slowly drift to the edge of space at 120,000 feet (
Then, I would assume, he will slowly step out onto something resembling an Olympic diving platform.
Below, the Earth become 34、s the concrete bottom of a swimming pool that he wants to land on, but not too hard. Still, hell be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. It will be like he is diving into the shallow end.
Skydiver preps for the big jump
When he jumps, he 35、is expected to reach the speed of sound -- 690 mph (1,110 kph) -- in less than 40 seconds. Like hitting the top of the water, he will begin to slow as he approaches the more dense air closer to Earth. But this will not be enough to stop him completely.
If he goes too fast or spins out of control, 36、he has a stabilization parachute that can be deployed to slow him down. His team hopes its not needed. Instead, he plans to deploy his 270-square-foot (25-square-meter) main chute at an altitude of around 5,000 feet (1,524 meters).
In order to deploy this chute successfully, he will have to slow to 37、 172 mph (277 kph). He will have a reserve parachute that will open automatically if he loses consciousness at mach speeds.
Even if everything goes as planned, it wont. Baumgartner still will free fall at a speed that would cause you and me to pass out, and no parachute is guaranteed to work higher than 25,000 feet (7,620 meters).
cause there
- 溫馨提示:
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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 市教育局冬季運(yùn)動會安全工作預(yù)案
- 2024年秋季《思想道德與法治》大作業(yè)及答案3套試卷
- 2024年教師年度考核表個人工作總結(jié)(可編輯)
- 2024年xx村兩委涉案資金退還保證書
- 2024年憲法宣傳周活動總結(jié)+在機(jī)關(guān)“弘揚(yáng)憲法精神推動發(fā)改工作高質(zhì)量發(fā)展”專題宣講報告會上的講話
- 2024年XX村合作社年報總結(jié)
- 2024-2025年秋季第一學(xué)期初中歷史上冊教研組工作總結(jié)
- 2024年小學(xué)高級教師年終工作總結(jié)匯報
- 2024-2025年秋季第一學(xué)期初中物理上冊教研組工作總結(jié)
- 2024年xx鎮(zhèn)交通年度總結(jié)
- 2024-2025年秋季第一學(xué)期小學(xué)語文教師工作總結(jié)
- 2024年XX村陳規(guī)陋習(xí)整治報告
- 2025年學(xué)校元旦迎新盛典活動策劃方案
- 2024年學(xué)校周邊安全隱患自查報告
- 2024年XX鎮(zhèn)農(nóng)村規(guī)劃管控述職報告