Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _09._Longer_Line
- {
- class Longer_Line
- {
- static void Main(string[] args)
- {
- double x1 = double.Parse(Console.ReadLine());
- double y1 = double.Parse(Console.ReadLine());
- double x2 = double.Parse(Console.ReadLine());
- double y2 = double.Parse(Console.ReadLine());
- double x3 = double.Parse(Console.ReadLine());
- double y3 = double.Parse(Console.ReadLine());
- double x4 = double.Parse(Console.ReadLine());
- double y4 = double.Parse(Console.ReadLine());
- double firstFigureX = x1 - x2;
- double firstFigureY = y1 - y2;
- double secondFigureX = x3 - x4;
- double secondFigureY = x3 - x4;
- double diagonal1 = Math.Sqrt(Math.Pow(firstFigureX, 2) + Math.Pow(firstFigureY, 2));
- double diagonal2 = Math.Sqrt(Math.Pow(secondFigureX, 2) + Math.Pow(secondFigureY, 2));
- double closerXFirstFigure = Math.Min(Math.Abs(x1), Math.Abs(x2));
- double closerYFirstFigure = Math.Min(Math.Abs(y1), Math.Abs(y2));
- double closerXSecondFigure = Math.Min(Math.Abs(x3), Math.Abs(x4));
- double closerYSecondFigure = Math.Min(Math.Abs(y3), Math.Abs(y4));
- if (diagonal1 >= diagonal2)
- {
- if (closerXFirstFigure == x1 && closerXFirstFigure <= closerYFirstFigure)
- {
- Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
- }
- else if (closerXFirstFigure == x2 && closerXFirstFigure <= closerYFirstFigure)
- {
- Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
- }
- else if (closerYFirstFigure == y1)
- {
- Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
- }
- else
- {
- Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
- }
- }
- else
- {
- if (closerXSecondFigure == x3 && closerXSecondFigure <= closerYSecondFigure)
- {
- Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
- }
- else if (closerXSecondFigure == x4 && closerXSecondFigure <= closerYSecondFigure)
- {
- Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
- }
- else if (closerYFirstFigure == y3)
- {
- Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
- }
- else
- {
- Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment