Advertisement
Guest User

08. Center Point

a guest
Oct 4th, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _8.Center_Point
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double x1 = double.Parse(Console.ReadLine());
  14.             double y1 = double.Parse(Console.ReadLine());
  15.             double x2 = double.Parse(Console.ReadLine());
  16.             double y2 = double.Parse(Console.ReadLine());
  17.  
  18.             ClosestPoint(x1,y1,x2,y2);
  19.         }
  20.         private static void ClosestPoint(double x1, double y1, double x2, double y2)
  21.         {
  22.             if ((Math.Abs(x1) <= Math.Abs(x2) && Math.Abs(y1) <= Math.Abs(y2)))
  23.                 Console.WriteLine($"({x1}, {y1})");
  24.             else if (Math.Abs(x1)<=Math.Abs(x2) && Math.Abs(y1)>=Math.Abs(y2))
  25.                 Console.WriteLine($"({x1}, {y2})");
  26.             else if (Math.Abs(x1)>=Math.Abs(x2) && Math.Abs(y1)<=Math.Abs(y2))
  27.                 Console.WriteLine($"({x2}, {y1})");
  28.             else if (Math.Abs(x1) >= Math.Abs(x2) && Math.Abs(y1) >= Math.Abs(y2))
  29.                 Console.WriteLine($"({x2}, {y2})");
  30.             else if ((Math.Abs(x1) == Math.Abs(x2) && Math.Abs(x2) == Math.Abs(y1) && Math.Abs(y1) == Math.Abs(y2)))
  31.                 Console.WriteLine($"({x1}, {x1})");
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement