Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace LongerLine
- {
- class Program
- {
- 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 lenghtLine1 = CalculateLineLenght(x1, y1, x2, y2);
- //double lenghtLine2 = CalculateLineLenght(x2, y2, x3, y3);
- double lenghtLine1 = CalculateLineLenght(x1, y1, x2, y2);
- double lenghtLine2 = CalculateLineLenght(x3, y3, x4, y4);
- if (lenghtLine1 >= lenghtLine2)
- {
- bool isClosest = CheckClosestToZero(x1, y1, x2, y2);
- if (isClosest)
- {
- Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
- }
- else
- {
- Console.WriteLine($"({x2}, {y2})({x1}, {y1})");
- }
- }
- else
- {
- bool isClosest = CheckClosestToZero(x3, y3, x4, y4);
- if (isClosest)
- {
- Console.WriteLine($"({x3}, {y3})({x4}, {y4})");
- }
- else
- {
- Console.WriteLine($"({x4}, {y4})({x3}, {y3})");
- }
- }
- }
- static double CalculateLineLenght(double x1, double y1, double x2, double y2)
- {
- return Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
- }
- static bool CheckClosestToZero(double x1, double y1, double x2, double y2)
- {
- double distance1 = Math.Sqrt(Math.Pow(x1, 2) + Math.Pow(y1, 2));
- double distance2 = Math.Sqrt(Math.Pow(x2, 2) + Math.Pow(y2, 2));
- if (distance1 <= distance2)
- {
- return true;
- }
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment