Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _5_2_09_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 lengthL1 = GetLength(x1, y1, x2, y2);
- double lengthL2 = GetLength(x3, y3, x4, y4);
- if (lengthL1 > lengthL2)
- {
- string smalLentToZero1 = GetSmallestLengthToZero1(x1, y1, x2, y2);
- Console.WriteLine(smalLentToZero1);
- }
- else if (lengthL1 < lengthL2)
- {
- string smalLentToZero2 = GetSmallestLengthToZero2(x3, y3, x4, y4);
- Console.WriteLine(smalLentToZero2);
- }
- else
- {
- Console.WriteLine($"({x1}, {y1})({x2}, {y2})");
- }
- }
- static string GetSmallestLengthToZero1(double x1, double y1, double x2, double y2)
- {
- double lengthL10 = GetLengthToZeroPoint(x1, y1);
- double lengthL20 = GetLengthToZeroPoint(x2, y2);
- string smalLentToZero1 = string.Empty;
- if (lengthL10 < lengthL20)
- {
- smalLentToZero1 = ($"({x1}, {y1})({x2}, {y2})");
- }
- else if (lengthL10 >= lengthL20)
- {
- smalLentToZero1 = ($"({x2}, {y2})({x1}, {y1})");
- }
- return smalLentToZero1;
- }
- static string GetSmallestLengthToZero2(double x3, double y3, double x4, double y4)
- {
- double lengthL30 = GetLengthToZeroPoint(x3, y3);
- double lengthL40 = GetLengthToZeroPoint(x4, y4);
- string smalLentToZero2 = string.Empty;
- if (lengthL30 < lengthL40)
- {
- smalLentToZero2 = ($"({x3}, {y3})({x4}, {y4})");
- }
- else if (lengthL30 >= lengthL40)
- {
- smalLentToZero2 = ($"({x4}, {y4})({x3}, {y3})");
- }
- return smalLentToZero2;
- }
- static double GetLengthToZeroPoint(double x, double y)
- {
- return Math.Sqrt(Math.Pow((x), 2) + Math.Pow(y, 2));
- }
- static double GetLength(double xOne, double yOne, double xTwo, double yTwo)
- {
- double x = Math.Abs(xOne - xTwo);
- double y = Math.Abs(yOne - yTwo);
- return Math.Sqrt(Math.Pow((x), 2) + Math.Pow(y, 2));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment