Advertisement
4valeri

Take The Plane Down

Feb 6th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4.     class MyPlane
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             int firstRow = int.Parse(Console.ReadLine());
  9.             int secondRow = int.Parse(Console.ReadLine());
  10.             int countryRadius = int.Parse(Console.ReadLine());
  11.  
  12.             int detectedPlanes = int.Parse(Console.ReadLine());
  13.             for (int plane = 0; plane < detectedPlanes; plane++)
  14.             {
  15.                 int planeX = int.Parse(Console.ReadLine());
  16.                 int planeY = int.Parse(Console.ReadLine());
  17.  
  18.                 int planeDistanceX = planeX - firstRow;
  19.                 int planeDistanceY = planeY - secondRow;
  20.  
  21.                 double distanceToPlane = Math.Sqrt((planeDistanceX * planeDistanceX) + (planeDistanceY * planeDistanceY));
  22.  
  23.                 if (countryRadius >= distanceToPlane)
  24.                 {
  25.                     Console.WriteLine("You destroyed a plane at [{0},{1}]", planeX, planeY);
  26.                 }
  27.             }
  28.         }
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement