Advertisement
Guest User

09_Longer_Line

a guest
Jul 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _09_Longer_Line
  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.             double x3 = double.Parse(Console.ReadLine());
  14.             double y3 = double.Parse(Console.ReadLine());
  15.             double x4 = double.Parse(Console.ReadLine());
  16.             double y4 = double.Parse(Console.ReadLine());
  17.  
  18.             Console.WriteLine(CenterPoint(x1, y1, x2, y2, x3, y3, x4, y4));
  19.         }
  20.  
  21.         static string CenterPoint(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
  22.         {
  23.             double combinationOne = Math.Abs(x1) + Math.Abs(y1);
  24.             double combinationTwo = Math.Abs(x2) + Math.Abs(y2);
  25.             double combinationOneTwo = Math.Abs(combinationOne) + Math.Abs(combinationTwo);
  26.  
  27.             double combinationThree = Math.Abs(x3) + Math.Abs(y3);
  28.             double combinationFour = Math.Abs(x4) + Math.Abs(y4);
  29.             double combinationThreeFour = Math.Abs(combinationThree) + Math.Abs(combinationFour);
  30.  
  31.             string result = "";
  32.             if (combinationOneTwo >= combinationThreeFour)
  33.             {
  34.                 if (combinationOne <= combinationTwo)
  35.                 {
  36.                     result = $"({x1}, {y1})({x2}, {y2})";
  37.                 }
  38.  
  39.                 else
  40.                 {
  41.                     result = $"({x2}, {y2})({x1}, {y1})";
  42.                 }
  43.             }
  44.  
  45.             else
  46.             {
  47.                 if (combinationOne <= combinationTwo)
  48.                 {
  49.                     result = $"({x3}, {y3})({x4}, {y4})";
  50.                 }
  51.                 else
  52.                 {
  53.                     result = $"({x4}, {y4})({x3}, {y3})";
  54.                 }
  55.             }
  56.  
  57.             return result;
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement