Problem D 駕駛員與汽車

2021-07-31 21:53:46 字數 2091 閱讀 7966

home

web board

problemset

standing

status

statistics

time limit: 1 sec  

memory limit: 128 mb

submit: 2573  

solved: 1091 [

submit][

status][

web board]

我們知道,目前我國的駕照大致可分為a、b、c三種,其中c證只能開小型客車(貨車),b證可開中、小型客車(貨車),a證沒有限制。現在請定義如下幾個類:

1. automobile:抽象類,具有資料成員double speed,純虛函式virtual void run() const = 0。

2. 六種車型,即小型車benz、buick;中型車zhongba、beiqi;以及大型車dayu、jianghuai。它們都是automobile的子類。

3. driver類,具有string name和char type兩個資料成員,前者是司機的名字,後者是司機持有的駕照型別(a、b或c)。提供drive(automobile *)方法,根據駕照型別判定該司機是否可以駕駛指定的汽車。

輸入分多行。第一行是乙個整數m>0,表示之後有m個測試用例。

每個測試用例包括四部分:司機姓名(不含空白符)、駕照型別(a、b或c)、車型(分別用字母a~f表示六種車型,對應的車型可以從main()中看出)以及該車的行駛速度(double型別範圍內的正數)。

輸出共m行,每個測試用例對應一行輸入,具體格式參見樣例。

4zhangsan c a 100.33lisi c d 100.33wangwu b f 100.33tom a e 300.00

driver zhangsan can drive benz at speed of 100.33km/h.a benz is erased!an automobile is erased!driver lisi cannot drive bus.a beiqi is erased!an automobile is erased!driver wangwu cannot drive large bus.a jianghuai is erased!an automobile is erased!driver tom can drive dayu at speed of 300.00km/h.a dayu is erased!an automobile is erased!

1.使用typeid來判定乙個基類指標實際指向的物件的型別。 [

submit][

status][

web board]

한국어<  

中文فارسی

english

ไทย 2003-2011 hustoj project team

anything about the problems, please contact admin:admin

#include #include #include #include using namespace std;

class automobile

virtual ~automobile()

public:

virtual void run() const = 0;

};class benz :virtual public automobile

~benz()

void run() const };

class buick :virtual public automobile

~buick()

void run() const

break;

case 'c':

if (typeid(*automobile) != typeid(benz) && typeid(*automobile) != typeid(buick))

cout<<"driver "}

break;

}}int main()

driver.drive(automobile);

delete automobile;

}return 0;

}

1781 駕駛員與汽車

我們知道,目前我國的駕照大致可分為a b c三種,其中c證只能開小型客車 貨車 b證可開中 小型客車 貨車 a證沒有限制。現在請定義如下幾個類 1.automobile 抽象類,具有資料成員double speed,純虛函式virtual void run const 0。2.六種車型,即小型車be...

儀表和駕駛員資訊介面

儀表包括車速表 燃油表等其他相關指示。當電源模式為 on 時顯示。按下 主頁 按鈕,滾動左選擇器輪滾動到想要檢視的內容。按下左選擇器輪檢視詳細資訊。當電源模式處於 on 車輛完全停止狀態且檔位處於 p 時,按下 主頁 按鈕,滾動左選擇器輪選擇 設定 畫面,然後按左選擇器輪,根據喜好更改設定。當電源模...

無人駕駛汽車違法誰擔責?深圳市明確了 駕駛員不扣分

未來,汽車的自動駕駛能力,肯定會是其必備的一項技能。但是技術畢竟不等同於程式設計客棧人類駕駛員,如果自動駕駛發生了交通違法,那麼該由誰擔責呢?針對這一問題,深www.cppcns.com圳市給出了自己的政策規則。據報道,在8月30日的深圳市七屆人大常委會三次會議上,審議了 深圳經濟特區智慧型網聯汽車...