Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ballistics_training
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] coordinates = Console.ReadLine().Split(' ');
- string[] input = Console.ReadLine().Split(' ');
- string[] commands = new string[input.Length/2];
- int tempCount = 0;
- for (int i = 0; i < commands.Length; i++)
- {
- commands[i] = input[tempCount];
- tempCount += 2;
- }
- tempCount = 1;
- string[] moves = new string[commands.Length];
- for (int i = 0; i < moves.Length; i++)
- {
- moves[i] = input[tempCount];
- tempCount += 2;
- }
- double x = 0;
- double y = 0;
- for (int i = 0; i < commands.Length; i++)
- {
- if (commands[i] == "left")
- {
- x -= double.Parse(moves[i]);
- }
- else if (commands[i] == "right")
- {
- x += double.Parse(moves[i]);
- }
- else if (commands[i] == "up")
- {
- y += double.Parse(moves[i]);
- }
- else if (commands[i] == "down")
- {
- y -= double.Parse(moves[i]);
- }
- }
- if (x == double.Parse(coordinates[0]) && y == double.Parse(coordinates[1]))
- {
- Console.WriteLine($"firing at [{x}, {y}]");
- Console.WriteLine("got 'em!");
- }
- else
- {
- Console.WriteLine($"firing at [{x}, {y}]");
- Console.WriteLine("better luck next time...");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement