zhivko1985

Longer Line

Dec 28th, 2018
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _09._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.  
  18.  
  19. double firstFigureX = x1 - x2;
  20. double firstFigureY = y1 - y2;
  21. double secondFigureX = x3 - x4;
  22. double secondFigureY = x3 - x4;
  23.  
  24. double diagonal1 = Math.Sqrt(Math.Pow(firstFigureX, 2) + Math.Pow(firstFigureY, 2));
  25. double diagonal2 = Math.Sqrt(Math.Pow(secondFigureX, 2) + Math.Pow(secondFigureY, 2));
  26.  
  27. double closerXFirstFigure = Math.Min(Math.Abs(x1), Math.Abs(x2));
  28. double closerYFirstFigure = Math.Min(Math.Abs(y1), Math.Abs(y2));
  29. double closerXSecondFigure = Math.Min(Math.Abs(x3), Math.Abs(x4));
  30. double closerYSecondFigure = Math.Min(Math.Abs(y3), Math.Abs(y4));
  31.  
  32. if (diagonal1 >= diagonal2)
  33. {
  34. if (closerXFirstFigure == x1 && closerXFirstFigure <= closerYFirstFigure)
  35. {
  36. Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
  37. }
  38. else if (closerXFirstFigure == x2 && closerXFirstFigure <= closerYFirstFigure)
  39. {
  40. Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
  41. }
  42. else if (closerYFirstFigure == y1)
  43. {
  44. Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
  45. }
  46. else
  47. {
  48. Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
  49. }
  50. }
  51. else
  52. {
  53. if (closerXSecondFigure == x3 && closerXSecondFigure <= closerYSecondFigure)
  54. {
  55. Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
  56. }
  57. else if (closerXSecondFigure == x4 && closerXSecondFigure <= closerYSecondFigure)
  58. {
  59. Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
  60. }
  61. else if (closerYFirstFigure == y3)
  62. {
  63. Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
  64. }
  65. else
  66. {
  67. Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
  68. }
  69. }
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment