public static void Main() { int[] galaxyDimestions = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray(); Galaxy galaxy = new Galaxy(galaxyDimestions[0], galaxyDimestions[1]); long sum = 0; string command; while ((command = Console.ReadLine()) != "Let the Force be with you") { int[] ivoStartPoint = command .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse) .ToArray(); Ivo ivo = new Ivo(ivoStartPoint); int[] evilStartPoint = Console .ReadLine() .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse) .ToArray(); Evil evil = new Evil(evilStartPoint); while (evil.IsMoveAcross() && ivo.IsMoveAcross()) { if (evil.IsOnTheGalaxy(galaxy)) { evil.Destroy(galaxy); } evil.Move(); if (ivo.IsOnTheGalaxy(galaxy)) { sum += ivo.GetValue(galaxy); } ivo.Move(); } } Console.WriteLine(sum); }
static void Main() { string[] dimensionSizes = Console.ReadLine().Split(" "); int x = int.Parse(dimensionSizes[0]); int y = int.Parse(dimensionSizes[1]); int[,] matrix = new int[x, y]; int value = 0; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { matrix[i, j] = value++; } } string command = Console.ReadLine(); while (command != "Let the Force be with you") { string[] aCommand = command.Split(" "); Ivo ivo = new Ivo(int.Parse(aCommand[0]), int.Parse(aCommand[1])); aCommand = Console.ReadLine().Split(" "); Evil evil = new Evil(int.Parse(aCommand[0]), int.Parse(aCommand[1])); evil.Move(matrix); ivo.Move(matrix); command = Console.ReadLine(); } Console.WriteLine(Ivo.Sum); }