Advertisement
martinvalchev

Center_Point

Feb 2nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Center_Point
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double x1 = double.Parse(Console.ReadLine());
  10.             double y1 = double.Parse(Console.ReadLine());
  11.             double x2 = double.Parse(Console.ReadLine());
  12.             double y2 = double.Parse(Console.ReadLine());
  13.  
  14.             string closesPoint = FindClosesPont(x1, y1, x2, y2);
  15.             if (closesPoint == "first")
  16.             {
  17.                 Console.WriteLine($"({x1}, {y1})");
  18.  
  19.             }
  20.             else
  21.             {
  22.                 Console.WriteLine($"({x2}, {y2})");
  23.             }
  24.  
  25.         }
  26.  
  27.          static string FindClosesPont(double x1, double y1, double x2, double y2)
  28.         {
  29.             double distance1 = Math.Sqrt(x1 * x1 + y1 * y1);
  30.             double distance2 = Math.Sqrt(x2 * x2 + y2 * y2);
  31.            
  32.             if (distance1 > distance2)
  33.             {
  34.                 return "second";
  35.             }
  36.             else
  37.             {
  38.                 return "first";
  39.             }
  40.            
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement