Problem B 學校的構成(I)

2021-09-20 13:30:15 字數 1328 閱讀 5666

學校是老師和學生組成的。現在定義student、teacher和school三個類來模擬乙個學校。

student類只有乙個int型別的資料成員,表示學生的年級;teacher類只有乙個double型別的資料成員,表示該教師的工資;school類是由1個student類的物件、1個teacher類的物件組合而成。定義它們的建構函式和析構函式,使程式能產生樣例所示的輸出。

輸入4行,第1行和第3行是2個int型別的正整數;第2行和第4行是double型別的正數。

見樣例。

3

1600.31

42451.34

a student grade 3 is created.

a teacher with salary 1600.31 is created.

a school is created.

a student grade 4 is created.

a teacher with salary 2451.34 is created.

a student grade 4 is created.

a teacher with salary 2451.34 is created.

a school is created.

a school is erased.

a teacher with salary 2451.34 is erased.

a student grade 4 is erased.

a teacher with salary 2451.34 is erased.

a student grade 4 is erased.

a school is erased.

a teacher with salary 1600.31 is erased.

a student grade 3 is erased.

int main()

#include

using namespace std;

class

student

~student()

};class

teacher

~teacher()

};class

school

~school()

};int main()

湘潭大學校賽I

accepted 58 submit 349 time limit 5000 ms memory limit 65536 kb 作為一名即將畢業大學生,小明即將參加一系列的面試,每場面試都有乙個開始時間 si和乙個結束時間 ti。小明可以選擇參加面試或者放棄面試,但是遲到和早退是不允許的。每場面試對...

Problem B 殘缺的棋盤

在西洋棋裡,王是最重要的乙個棋子。每一步,王可以往上下左右或者對角線方向移動一 步,如下圖所示。給定兩個格仔 a r1,c1 b r2,c2 你的任務是計算出乙個王從 a 到 b 至少需要走多少步。為了 避免題目太簡單,我們從棋盤裡拿掉了乙個格仔 c r3,c3 abc 保證互不相同 要求王從 a ...

Problem B 新奇的加法運算

time limit 1 sec memory limit 128 mb submit 292 solved 120 submit status web board 定義類newint,包括 1.int型別的資料成員。2.過載運算子 計算規則為 將a b對應位置上的數字相加,只保留個位數作為結果的對...