Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _1._10.Ballistics_Training
- {
- using System;
- public class BallisticsTrain
- {
- public static void Main()
- {
- string[] targetCoordinates = Console.ReadLine().Split(' ');
- string[] commands = Console.ReadLine().Split(' ');
- double[] parsedCoordinates = new double[targetCoordinates.Length];
- for (int i = 0; i < targetCoordinates.Length; i++)
- {
- parsedCoordinates[i] = double.Parse(targetCoordinates[i]);
- }
- double x = 0.0;
- double y = 0.0;
- for (int i = 0; i < commands.Length; i += 2)
- {
- if (commands[i] == "up")
- {
- y += double.Parse(commands[i + 1]);
- }
- if (commands[i] == "down")
- {
- y -= double.Parse(commands[i + 1]);
- }
- if (commands[i] == "right")
- {
- x += double.Parse(commands[i + 1]);
- }
- if (commands[i] == "left")
- {
- x -= double.Parse(commands[i + 1]);
- }
- }
- if (x == parsedCoordinates[0] && y == parsedCoordinates[1])
- {
- Console.WriteLine($"firing at [{parsedCoordinates[0]}, {parsedCoordinates[1]}]");
- Console.WriteLine($"got 'em!");
- }
- else
- {
- Console.WriteLine($"firing at [{parsedCoordinates[0]}, {parsedCoordinates[1]}]");
- Console.WriteLine($"better luck next time...");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement