Describe 데블스캠프2010/다섯째날/ObjectCraft/미션2/강소현 here
#include <stdio.h> #include <stdlib.h> typedef struct zergling{ char *name; int attack; int protect; int HP; }zerg; void AAttackB(zerg *a, zerg *b){ b->HP -= a->attack; } int main(){ zerg zerg1={"저그1",5,0,50}, zerg2={"저그2",5,0,50}; int order; while(zerg2.HP > 0 && zerg1.HP >0){ order = (int) rand() % 2; if(order == 0){ AAttackB(&zerg1,&zerg2); printf("%s가 %s에게 데미지 %d를 입혀 HP가 %d가 되었다.\n",zerg1.name, zerg2.name, zerg1.attack, zerg2.HP); }else{ AAttackB(&zerg2,&zerg1); printf("%s가 %s에게 데미지 %d를 입혀 HP가 %d가 되었다.\n",zerg2.name, zerg1.name, zerg2.attack, zerg1.HP); } } puts("--------------------------------------------------"); printf("게임 끝 ㅇㅇ\n"); return 0; }