Advertisement
koksibg

Longer_Line

Oct 3rd, 2016
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Longer_Line
  4. {
  5.     class Longer_Line
  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.             CheckAndPrintDistance(x1, y1, x2, y2, x3, y3, x4, y4);
  18.         }
  19.  
  20.         public static double Distance(double x, double y)
  21.         {
  22.             double distance = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
  23.             return distance;
  24.         }
  25.  
  26.         public static void CheckAndPrintDistance
  27.         (double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
  28.  
  29.         {
  30.             double distancePoint1 = Distance(x1, y1);
  31.             double distancePoint2 = Distance(x2, y2);
  32.             double distancePoint3 = Distance(x3, y3);
  33.             double distancePoint4 = Distance(x4, y4);
  34.             double lengthPoint12 = Math.Sqrt(Math.Pow((x1 - x2), 2) + Math.Pow((y1 - y2), 2));
  35.             double lengthPoint34 = Math.Sqrt(Math.Pow((x3 - x4), 2) + Math.Pow((y3 - y4), 2));
  36.             if (lengthPoint12 >= lengthPoint34)
  37.             {
  38.                 if (distancePoint1 <= distancePoint2)
  39.                     Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
  40.                 else Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
  41.             }
  42.             if (lengthPoint12 < lengthPoint34)
  43.             {
  44.                 if (distancePoint3 <= distancePoint4)
  45.                     Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
  46.                 else Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement