发布
loading-left
loading loading loading
loading-right

加载中

个人主页
TA还没有准备介绍自己
TA的源代码 (3)
时间之差
暂无评分
Description 定义一个类Time,包含小时、分钟、秒三个属性。定义其构造函数Time(int,int,int)分别初始化其小时、分钟、秒。重载减法运算符,用于求两个时间之间相差的秒数(非负整数)。 Input 输入有2行。每行表示1个时间,包括小时、分钟、秒三个值。输入都是合法的24小时制的时间。
Kim_Junghyun
2020-06-30
0
1
玩家PK
暂无评分
#include<iostream> #include<cmath> #include<algorithm> #include<iomanip> #include<string> #include<cstring> usingnamespacestd; classRole { protected: inthp,ce,de,fa; intflag; stringnn; public: Role(stringn,inth,intc,intd,intf):nn(n),hp(h),ce(c),de(d),fa(f){} ~Role(){} voidcombat(Role&an) { if(fa>an.fa) { flag=1; loop2: cout<<nn<<"attacks"<<an.nn<<":"; if(an.de>=ce) { an.hp--; an.de--; } else { an.hp=an.hp-ce+an.de; an.de--; } if(an.hp<0) { an.hp=0; } if(an.de<0) { an.de=0; } cout<<an.nn<<"hp="&
Kim_Junghyun
2020-06-30
0
1
家禽和家畜
暂无评分
农户家里通常要养一些家禽、家畜,它们吃的东西和作用不同。现在用多态来描述这种情况。 定义类Animal,是一个抽象类,有纯虚函数voideat()和voidfun(),分别用于展示动物吃的行为和作用。 定义Animal的子类Cat、Dog和Rooster,分别是猫、狗和公鸡类。 对于Cat类,eat()输出“Cateatsfishes.”;fun()输出“Catcatchesmouses.”。
Kim_Junghyun
2020-06-30
0
1
没有更多了~