Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _09.longerLine
- {
- class Program
- {
- static void Main(string[] args)
- {
- var xOne = double.Parse(Console.ReadLine());
- var yOne = double.Parse(Console.ReadLine());
- var xTwo = double.Parse(Console.ReadLine());
- var yTwo = double.Parse(Console.ReadLine());
- var xThree = double.Parse(Console.ReadLine());
- var yThree = double.Parse(Console.ReadLine());
- var xFour = double.Parse(Console.ReadLine());
- var yFour = double.Parse(Console.ReadLine());
- var betweenOne = DistanceMath(xOne, yOne, xTwo, yTwo);
- var betweenTwo = DistanceMath(xThree, yThree, xFour, yFour);
- if (betweenOne >= betweenTwo)
- {
- ClosestPoint(xOne, yOne, xTwo, yTwo);
- }
- else
- {
- ClosestPoint(xThree, yThree, xFour, yFour);
- }
- }
- public static double DistanceMath(double xfirst, double yfirst, double xSecond, double ySecond)
- {
- var calculationLength = Math.Sqrt(Math.Pow((xSecond - xfirst), 2) + (Math.Pow((ySecond - yfirst), 2)));
- return calculationLength;
- }
- public static void ClosestPoint(double firstX, double firstY, double secondX, double secondY)
- {
- if (Math.Abs(firstX) <= Math.Abs(secondX) && Math.Abs(firstY) <= Math.Abs(secondY))
- {
- Console.Write($"({firstX}, {firstY})");
- Console.WriteLine($"({secondX}, {secondY})");
- }
- else
- {
- Console.Write($"({secondX}, {secondY})");
- Console.WriteLine($"({firstX}, {firstY})");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement