Advertisement
Spocoman

02. Center Point

Jan 30th, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CenterPoint
  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.             ClosestToTheCenter(x1, x2, y1, y2);
  15.         }
  16.  
  17.         static void ClosestToTheCenter(double x1, double x2, double y1, double y2)
  18.         {
  19.             if (Math.Abs(x1 * x1 + y1 * y1) < Math.Abs(x2 * x2 + y2 * y2))
  20.             {
  21.                 Console.WriteLine($"({x1}, {y1})");
  22.             }
  23.             else
  24.             {
  25.                 Console.WriteLine($"({x2}, {y2})");
  26.             }
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement