#include <iostream>
using namespace std;
int blood=10000;
class Hero
{
protected:
string name;
int hp;
int attck;
public:
Hero()
{}
Hero(string name,int hp,int attck):name(name),hp(hp),attck(attck)
{}
virtual void Atk()
{
blood-=0;
}
};
class caster:public Hero
{
int ap_atk=50;
public:
void Atk()
{
blood-=(attck+ap_atk);
}
caster(string name,int hp,int attck,int ap_atk):Hero(name,hp,attck),ap_atk(ap_atk){}
caster(){}
};
class archer:public Hero
{
int ad_atk=100;
public:
void Atk()
{
blood-=(attck+ad_atk);
}
archer(string name,int hp,int attck,int ad_atk):Hero(name,hp,attck),ad_atk(ad_atk){}
archer(){}
};
int main()
{
int t=0;
caster c1("kk",12,13,14);
archer a1("mm",90,100,110);
while(blood>0)
{
c1.Atk();
a1.Atk();
t++;
}
cout<<t<<endl;
return 0;
}
1.2作业
最新推荐文章于 2024-11-16 21:36:47 发布