U E D R , A S I H C RSS

데블스캠프2010/다섯째날/ObjectCraft/미션3/김상호 (rev. 1.1)

데블스캠프2010/다섯째날/Object Craft/미션3/김상호

typedef struct z{
int gong;
int bang;
int hp;
int name;
}unit;

void attack(unit a, unit &b)
{
if(b.hp<=0 || a.hp<=0)
return;
b.hp -=a.gong;
printf("저글링 %d이 저글링 %d에게 데미지 %d를 입혀 HP가 %d가 되었다.\n", a.name, b.name, a.gong, b.hp);
if(b.hp==0)
printf("저글링 %d이 전사했습니다.\n", b.name);
}
void init_unit(unit aNUM){

int n;
for(n=0 ; n
an.gong=5;
an.bang=0;
an.hp=50;
an.name=n;
}
}
int main()
{
unit aNUM;
init_unit(a);
int sel;


srand(time(NULL));
while(!((a0.hp<=0 && a1.hp<=0) || (a2.hp<=0 && a3.hp<=0))) //0과 1이 죽으면 끝or 2와 3이 죽으면 끝
{

sel=rand()%(NUM*2);
int attackerTeam = rand() % 2;
int attackerUnit = rand() % 2;
int defenderunit = rand() % 2;

attack(aattackerTeam * 2 + attackerUnit,a(!attackerTeam) * 2 + defenderunit);
}
if(a0.hp<=0 && a1.hp<=0)
printf("뒷 팀이 이겼습니다!!\n");
if(a2.hp<=0 && a3.hp<=0)
printf("앞 팀이 이겼습니다!!\n");

return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:10
Processing time 0.0183 sec