Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _12.ToTheStars
- {
- using System;
- using System.Collections.Generic;
- class ToTheStars
- {
- static void Main(string[] args)
- {
- Dictionary<string, double[]> stars = new Dictionary<string, double[]>(3);
- string[] inputs = Console.ReadLine()
- .Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
- for (int i = 0; i < 3; i++)
- {
- string name = inputs[0].ToLower();
- double x = double.Parse(inputs[1]);
- double y = double.Parse(inputs[2]);
- stars[name] = new double[] { x, y };
- inputs = Console.ReadLine()
- .Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
- }
- double shipX = double.Parse(inputs[0]);
- double shipY = double.Parse(inputs[1]);
- int moves = int.Parse(Console.ReadLine());
- for (int i = 0; i <= moves; i++, shipY++)
- {
- CheckSpaceshipIsInTheRangeStarSystem(shipX, shipY, stars);
- }
- }
- private static void CheckSpaceshipIsInTheRangeStarSystem(double x, double y, Dictionary<string, double[]> stars)
- {
- bool isInRange = false;
- foreach (var star in stars)
- {
- double starMinX = star.Value[0] - 1;
- double starMaxX = star.Value[0] + 1;
- double starMinY = star.Value[1] - 1;
- double starMaxY = star.Value[1] + 1;
- if (x >= starMinX && x <= starMaxX && y >= starMinY && y <= starMaxY)
- {
- Console.WriteLine(star.Key);
- isInRange = true;
- break;
- }
- }
- if (!isInRange)
- {
- Console.WriteLine("space");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement