fk4m1913

Untitled

Jun 18th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1. using System;
  2.  
  3. namespace LongerLine
  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.             double firstLine = CalculateLine(x1, y1, x2, y2);
  19.             double secondLine = CalculateLine(x3, y3, x4, y4);
  20.  
  21.             if (firstLine >= secondLine)
  22.             {
  23.                 if (Math.Abs(x1) + Math.Abs(y1) <= Math.Abs(x2) + Math.Abs(y2))
  24.                 {
  25.                     Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
  26.                 }
  27.  
  28.                 else
  29.                 {
  30.                     Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
  31.                 }
  32.             }
  33.  
  34.             else
  35.             {
  36.                 if (Math.Abs(x3) + Math.Abs(y3) <= Math.Abs(x4) + Math.Abs(y4))
  37.                 {
  38.                     Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
  39.                 }
  40.  
  41.                 else
  42.                 {
  43.                     Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
  44.                 }
  45.             }
  46.         }
  47.  
  48.         static double CalculateLine(double x1, double y1, double x2, double y2)
  49.         {
  50.             double firstLine = Math.Abs(x1) + Math.Abs(y1) + Math.Abs(x2) + Math.Abs(y2);
  51.             return firstLine;
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment