Advertisement
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());
- LongerLine(x1,y1, x2, y2, x3, y3, x4,y4);
- }
- static void LongerLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
- {
- //double a = Math.Abs(x1) + Math.Abs(x2);
- //double b = Math.Abs(Math.Abs(y1) - Math.Abs(y2));
- //double c = Math.Abs(x3) + Math.Abs(x4);
- //double d = Math.Abs(Math.Abs(y3) - Math.Abs(y4));
- double a = x1 - x2;
- double b = y1 - y2;
- double c = x3 - x4;
- double d = y3 - y4;
- if (Math.Sqrt(a * a + b * b) >= Math.Sqrt(c * c + d * d))
- {
- ClosestPoint(x1, y1, x2, y2);
- }
- else
- {
- ClosestPoint(x3, y3, x4, y4);
- }
- }
- static void ClosestPoint(double x1, double x2, double x3, double x4)
- {
- if (Math.Sqrt(x1 * x1 + x2 * x2) <= Math.Sqrt(x3 * x3 + x4 * x4))
- {
- Console.Write($"({x1}, {x2})");
- Console.WriteLine($"({x3}, {x4})");
- }
- else
- {
- Console.Write($"({x3}, {x4})");
- Console.WriteLine($"({x1}, {x2})");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement