Advertisement
Guest User

Longer Line

a guest
Sep 26th, 2016
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2.  
  3. class LongerLine
  4. {
  5. static void Main()
  6. {
  7. double x1 = double.Parse(Console.ReadLine());
  8. double y1 = double.Parse(Console.ReadLine());
  9. double x2 = double.Parse(Console.ReadLine());
  10. double y2 = double.Parse(Console.ReadLine());
  11. double x3 = double.Parse(Console.ReadLine());
  12. double y3 = double.Parse(Console.ReadLine());
  13. double x4 = double.Parse(Console.ReadLine());
  14. double y4 = double.Parse(Console.ReadLine());
  15.  
  16. PrintLongerLine(x1, y1, x2, y2, x3, y3, x4, y4);
  17. }
  18.  
  19. static void PrintLongerLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
  20. {
  21. double firstLineLen = Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
  22. double secondLineLen = Math.Sqrt(Math.Pow((x4 - x3), 2) + Math.Pow((y4 - y3), 2));
  23.  
  24. if (firstLineLen >= secondLineLen)
  25. {
  26. if (Math.Abs(x1) <= Math.Abs(x2) && Math.Abs(y1) <= Math.Abs(y2))
  27. {
  28. Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
  29. }
  30. else
  31. {
  32. Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
  33. }
  34. }
  35. else
  36. {
  37. if (Math.Abs(x3) <= Math.Abs(x4) && Math.Abs(y3) <= Math.Abs(y4))
  38. {
  39. Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
  40. }
  41. else
  42. {
  43. Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
  44. }
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement