YankoGrancharov

long line

Oct 11th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.27 KB | None | 0 0
  1. using System;
  2. namespace Task9LongerLine
  3. {
  4.     class Task9LongerLine
  5.     {
  6.         static void FirstPoint(double a, double b, double c, double d)
  7.         {
  8.             double Point1 = Math.Sqrt(Math.Pow(a, 2) + Math.Pow(b, 2));
  9.             double Point2 = Math.Sqrt(Math.Pow(c, 2) + Math.Pow(d, 2));
  10.             if (Point1 == Point2)
  11.             {
  12.                 Console.WriteLine($"({a}, {b})({c}, {d})");
  13.             }
  14.             if (Point1 > Point2)
  15.             {
  16.                 Console.WriteLine($"({c}, {d})({a}, {b})");
  17.             }
  18.             if (Point1 < Point2)
  19.             {
  20.                 Console.WriteLine($"({a}, {b})({c}, {d})");
  21.             }
  22.         }
  23.         static double PodoubleDistans(double a, double b, double c, double d)
  24.         {
  25.            
  26.             double disttans = 0;
  27.             if (a==c)
  28.             {
  29.                 disttans = Math.Abs(b)+Math.Abs(d);
  30.             }
  31.             if (b==d)
  32.             {
  33.                 disttans = Math.Abs(a) + Math.Abs(c);
  34.             }
  35.             else
  36.             {
  37.                 double PodoubleDistans1 = Math.Pow(a, 2) + Math.Pow(b, 2);
  38.                 double PodoubleDistans2 = Math.Pow(c, 2) + Math.Pow(d, 2);
  39.                 disttans = Math.Sqrt(PodoubleDistans1 + PodoubleDistans2);
  40.             }
  41.             return disttans;
  42.         }
  43.         static void Main()
  44.         {
  45.             double x1 = double.Parse(Console.ReadLine());
  46.             double y1 = double.Parse(Console.ReadLine());
  47.             double x2 = double.Parse(Console.ReadLine());
  48.             double y2 = double.Parse(Console.ReadLine());
  49.             double x3 = double.Parse(Console.ReadLine());
  50.             double y3 = double.Parse(Console.ReadLine());
  51.             double x4 = double.Parse(Console.ReadLine());
  52.             double y4 = double.Parse(Console.ReadLine());
  53.             double l1 = PodoubleDistans(x1, y1, x2, y2);
  54.             double l2 = PodoubleDistans(x3, y3, x4, y4);
  55.             //if (l1==l2)
  56.             //{
  57.             //    FirstPoint(x1, y1, x2, y2);
  58.             //}
  59.             if (l1>=l2)
  60.             {
  61.                 FirstPoint(x1, y1, x2, y2);
  62.             }
  63.             if (l1<l2)
  64.             {
  65.                 FirstPoint(x3, y3, x4, y4);
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment