1.2.。。。。

有道云笔记

#include 

using namespace std;

int blood=10000;
class  hero
{
protected:
    string name;
    int hp;
    int attack;
public:
    hero(){}
    hero(string name,int hp,int attack):name(name),hp(hp),attack(attack)
    { }
    void atk()
    {
        blood-=0;
    }
};

class  master:public hero
{
private:
    int ap_atk=50;
public:
    master(){}
    master(string name,int hp,int attack):hero(name,hp,attack){}
    void atk()
    {
        blood-=attack+ap_atk;
    }
};

class  shooter:public hero
{
private:
    int ac_atk=50;
public:
    shooter(){}
    shooter(string name,int hp,int attack):hero(name,hp,attack){}
    void atk()
    {
        blood-=attack+ac_atk;
    }
};



int main()
{
    master m1("guanghui",1000,500);
    shooter s1("hanbin",1200,500);
    int count=0;
    while(blood>0)
    {
        m1.atk();
        if(blood>0)
        {
            s1.atk();
        }
        count++;
    }
    cout << count << endl;

//    hero *p=new shooter("baozou",900,500);
//    p->atk();
//    delete p;

    return 0;
}

你可能感兴趣的:(笔记)