anizko

02. Center Point

Jul 3rd, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02._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.             FineCenterPoint(x1, y1, x2, y2);
  15.         }
  16.  
  17.         static void FineCenterPoint(double x1, double y1, double x2, double y2)
  18.         {
  19.             double x = 0;
  20.             double y = 0;
  21.  
  22.             double divX1 = Math.Abs(x - x1);
  23.             double divY1 = Math.Abs(y - y1);
  24.             double divX2 = Math.Abs(x - x2);
  25.             double divY2 = Math.Abs(y - y2);
  26.  
  27.             double firstPoint = divX1 + divY1;
  28.             double secondPoint = divX2 + divY2;
  29.  
  30.             if (firstPoint <= secondPoint)
  31.             {
  32.                 Console.WriteLine($"({x1}, {y1})");
  33.             }
  34.             else
  35.             {
  36.                 Console.WriteLine($"({x2}, {y2})");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment