# 打倒魔王↖(^ω^)↗

//以下代码会自动添加到程序的开始
#include<iostream>
using namespace std;
class Role
{
public:
friend void judge(Role &,Role &);
void input()
{
cin>>HP>>ATK>>DEF;
}
private:
int HP;
int ATK;
int DEF;
};

//以下请给出 成员函数judge

//以下代码会自动添加到程序的末尾
int main()
{
Role monster,prince;
monster.input();
prince.input();
judge(monster,prince);
return 0;
}

``````9 6 2
8 5 3``````

``Trial!``

``````#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main()
{
int gx,gg,gf,wx,wg,wf;
scanf("%d%d%d",&gx,&gg,&gf);
scanf("%d%d%d",&wx,&wg,&wf);
while(gx>0&&wx>0)
{
gx=gx+gf-wg;
if(gx<=0)goto out;
else(wx=wx+wf-gg);
}out:
if(wx>gx)printf("Trial!");
else printf("You need more power!");
return 0;
}``````

``````
#include<iostream>
using namespace std;
class Role
{
public:
friend void judge(Role &,Role &);
void input()
{
cin>>HP>>ATK>>DEF;
}
private:
int HP;
int ATK;
int DEF;
};
void judge(Role &monster,Role &prince)
{
int hpm=monster.HP,hpl=prince.HP;
int T_A_m=monster.ATK-prince.DEF;  //王子每次损失的血量
int T_A_l=prince.ATK-monster.DEF;  //魔王每次损失的血量
if(prince.ATK<=monster.DEF)
{
cout<<"You need more power"<<endl;
return ;
}
if(monster.ATK<=prince.DEF)
{
cout<<"Trial!"<<endl;
return ;
}
while(hpm&&hpl)
{
hpm-=T_A_l;
if(hpm<=0)
break;
hpl-=T_A_m;
}
if(hpl>0)
cout<<"Trial!"<<endl;
else
cout<<"You need more power!"<<endl;
}
int main()
{
Role monster,prince;
monster.input();
prince.input();
judge(monster,prince);
return 0;
}
``````