Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _09.Longer_Line
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var x1 = double.Parse(Console.ReadLine());
  14.             var y1 = double.Parse(Console.ReadLine());
  15.             var x2 = double.Parse(Console.ReadLine());
  16.             var y2 = double.Parse(Console.ReadLine());
  17.             var x3 = double.Parse(Console.ReadLine());
  18.             var y3 = double.Parse(Console.ReadLine());
  19.             var x4 = double.Parse(Console.ReadLine());
  20.             var y4 = double.Parse(Console.ReadLine());
  21.  
  22.             var cordinate1 = Cordinates(x1, y1,x2,y2);
  23.             var cordinate2 = Cordinates(x3, y3,x4,y4);          
  24.                        
  25.             if (cordinate1>cordinate2)
  26.             {
  27.                 var cord1 = Close(x1, y1);
  28.                 var cord2 = Close(x2, y2);
  29.                 if (cord1<cord2)
  30.                     Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
  31.                 else if (cord2>cord1)
  32.                     Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
  33.             }
  34.             else if (cordinate1 <cordinate2)
  35.             {
  36.                 var cord3 = Close(x3, y3);
  37.                 var cord4 = Close(x4, y4);
  38.                 if (cord3 < cord4)
  39.                     Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
  40.                 else if (cord4 < cord3)
  41.                     Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
  42.  
  43.             }
  44.             else if (cordinate1 ==cordinate2)
  45.             {
  46.                 Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
  47.             }
  48.            
  49.         }
  50.         static double Cordinates(double x1, double y1, double x2, double y2)
  51.         {
  52.             double lineLength = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  53.             return lineLength;
  54.         }
  55.         static double Close(double x, double y)
  56.         {
  57.             double distance = Math.Sqrt(Math.Pow(x, 2) +
  58.                 Math.Pow(y, 2));
  59.             return distance;
  60.  
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement