Advertisement
VasilKotsev

Longer Line C#

Mar 22nd, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. namespace BlankProject
  7. {
  8.     class Program
  9.     {
  10.         static void Main()
  11.         {
  12.             double x1 = double.Parse(Console.ReadLine());
  13.             double y1 = double.Parse(Console.ReadLine());
  14.             double x2 = double.Parse(Console.ReadLine());
  15.             double y2 = double.Parse(Console.ReadLine());
  16.             double x3 = double.Parse(Console.ReadLine());
  17.             double y3 = double.Parse(Console.ReadLine());
  18.             double x4 = double.Parse(Console.ReadLine());
  19.             double y4 = double.Parse(Console.ReadLine());
  20.             CalcClosestPointToZero(x1, y1, x2, y2, x3, y3, x4, y4);
  21.  
  22.         }
  23.  
  24.         static void CalcClosestPointToZero(double x1, double y1, double x2, double y2,
  25.                                             double x3, double y3, double x4, double y4)
  26.         {
  27.             double pointOneCalc = Math.Sqrt((Math.Pow(x1, 2) + Math.Pow(y1, 2)));
  28.             double pointTwoCalc = Math.Sqrt((Math.Pow(x2, 2) + Math.Pow(y2, 2)));
  29.             double pointThreeCalc = Math.Sqrt((Math.Pow(x3, 2) + Math.Pow(y3, 2)));
  30.             double pointFourCalc = Math.Sqrt((Math.Pow(x4, 2) + Math.Pow(y4, 2)));
  31.  
  32.             double lineOne = pointOneCalc + pointTwoCalc;
  33.             double lineTwo = pointThreeCalc + pointFourCalc;
  34.  
  35.             string returnPoint;
  36.             returnPoint = (lineOne > lineTwo) ? $"({x1}, {y1})({x2}, {y2})" : $"({x4}, {y4})({x3}, {y3})";
  37.             Console.WriteLine(returnPoint);
  38.         }
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement