Advertisement
braveheart1989

Take_The_Plane_Down

Feb 14th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _02.Take_The_Plane_Down
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //•   On the first line you will be given the X of your headquarter.
  14.             double headquarterX = double.Parse(Console.ReadLine());
  15.             //•   On the second line you will be given the Y of your headquarter.
  16.             double headquarterY = double.Parse(Console.ReadLine());
  17.             //•   On the third line you will be given the distance from your headquarter to the borders.
  18.             double distanceToBorder = double.Parse(Console.ReadLine());
  19.             //•   On the fourth line you will be given the number of the planes that are approaching
  20.             double numberOfPlanes = double.Parse(Console.ReadLine());
  21.             int counter = 0;
  22.  
  23.             //On the next 2 * N lines you will be given:
  24.             while (counter < numberOfPlanes)
  25.             {
  26.                 //•   On the every odd line you will be given the plane X coordinate
  27.                 double planeX = double.Parse(Console.ReadLine());
  28.                 //•   on the every even line you will be given the plane Y coordinate
  29.                 double planeY = double.Parse(Console.ReadLine());
  30.                 counter++;
  31.                 bool isInside = Math.Pow(headquarterX - planeX, 2) + Math.Pow(headquarterY - planeY, 2)
  32.                     <= Math.Pow(distanceToBorder, 2);
  33.  
  34.                 if (isInside)
  35.                 {
  36.                     Console.WriteLine("You destroyed a plane at [{0},{1}]",planeX,planeY);
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement