Advertisement
bacco

Center Point

May 24th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CenterPoint
  4. {
  5.     class MainClass
  6.     {
  7.         public 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.             PrintCartesianPoint(x1, y1, x2, y2);
  15.         }
  16.  
  17.         static void PrintCartesianPoint(double x1,
  18.                                         double y1,
  19.                                         double x2,
  20.                                         double y2)
  21.         {
  22.             double firstPosition  = Math.Sqrt(x1 * x1 + y1 * y1);
  23.             double secondPosition = Math.Sqrt(x2 * x2 + y2 * y2);
  24.  
  25.             if (firstPosition <= secondPosition)
  26.             {
  27.                 Console.WriteLine($"({x1}, {y1})");
  28.             }
  29.             else
  30.             {
  31.                 Console.WriteLine($"({x2}, {y2})");
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement