TheBulgarianWolf

Closer point in Cartesian Coordinate System

Nov 2nd, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MoreMethodExercises
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int x1 = int.Parse(Console.ReadLine());
  10.             int y1 = int.Parse(Console.ReadLine());
  11.             int x2 = int.Parse(Console.ReadLine());
  12.             int y2 = int.Parse(Console.ReadLine());
  13.             double firstDistance = Math.Sqrt(Math.Pow(x1, 2) + Math.Pow(y1, 2));
  14.             double secondDistance = Math.Sqrt(Math.Pow(x2, 2) + Math.Pow(y2, 2));
  15.  
  16.             if(firstDistance < secondDistance)
  17.             {
  18.                 Console.WriteLine("({0},{1})",x1,y1);
  19.             }
  20.             else if(secondDistance < firstDistance)
  21.             {
  22.                 Console.WriteLine("({0},{1})",x2,y2);
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine("({0},{1})", x1, y1);
  27.             }
  28.         }
  29.     }
  30. }
  31.  
Add Comment
Please, Sign In to add comment