kirililchev3

Center Point

Jun 2nd, 2018
202
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 P08_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.             PrintCloserLine(x1, y1, x2, y2);
  15.         }
  16.  
  17.          static void PrintCloserLine(double x1, double y1, double x2, double y2)
  18.         {
  19.             double line1 = CalculatePythagorean(x1, y1);
  20.             double line2 = CalculatePythagorean(x2, y2);
  21.  
  22.             if (line1 <= line2)
  23.             {
  24.                 Console.WriteLine($"({x1}, {y1})");
  25.             }
  26.             else
  27.             {
  28.                 Console.WriteLine($"({x2}, {y2})");
  29.             }
  30.         }
  31.         static double CalculatePythagorean(double x, double y)
  32.         {
  33.              double result = Math.Sqrt(x * x + y * y);
  34.              return result;
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment