using System; namespace tstruct { class Program { struct Dog { public int hp; public int atk; public bool IsDead() { return hp<=0; } } static void PrintHP(Dog d) { Console.WriteLine("hp: {0}", d.hp); } static void Attack(Dog attacker, ref Dog defender) { if(attacker.hp<=0) return; if(defender.hp > attacker.atk) defender.hp -= attacker.atk; else defender.hp = 0; } static void SupAttack(Dog attacker, Dog [] dogs) { for(int i=0; i<dogs.Length; i++) Attack(attacker,ref dogs[i]); } public static void Main(string[] args) { Dog dang; Dog [] dums = new Dog[5]; dang.hp = 100; dang.atk = 2000; PrintHP(dang); for(int i=0; i<dums.Length; i++) { dums[i].atk = 5; dums[i].hp = 50; } foreach(Dog d in dums) Attack(d,ref dang); if(dang.IsDead()) Console.WriteLine("RIP Dang"); PrintHP(dang); SupAttack(dang,dums); for(int i=0; i<dums.Length; i++) PrintHP(dums[i]); Console.ReadLine(); } } }