Advertisement
Guest User

Untitled

a guest
Jan 27th, 2017
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _09.longerLine
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var xOne = double.Parse(Console.ReadLine());
  14. var yOne = double.Parse(Console.ReadLine());
  15.  
  16. var xTwo = double.Parse(Console.ReadLine());
  17. var yTwo = double.Parse(Console.ReadLine());
  18.  
  19. var xThree = double.Parse(Console.ReadLine());
  20. var yThree = double.Parse(Console.ReadLine());
  21.  
  22. var xFour = double.Parse(Console.ReadLine());
  23. var yFour = double.Parse(Console.ReadLine());
  24.  
  25. var betweenOne = DistanceMath(xOne, yOne, xTwo, yTwo);
  26. var betweenTwo = DistanceMath(xThree, yThree, xFour, yFour);
  27.  
  28. if (betweenOne >= betweenTwo)
  29. {
  30. ClosestPoint(xOne, yOne, xTwo, yTwo);
  31. }
  32. else
  33. {
  34. ClosestPoint(xThree, yThree, xFour, yFour);
  35. }
  36. }
  37.  
  38. public static double DistanceMath(double xfirst, double yfirst, double xSecond, double ySecond)
  39. {
  40. var calculationLength = Math.Sqrt(Math.Pow((xSecond - xfirst), 2) + (Math.Pow((ySecond - yfirst), 2)));
  41. return calculationLength;
  42. }
  43.  
  44. public static void ClosestPoint(double firstX, double firstY, double secondX, double secondY)
  45. {
  46. if (Math.Abs(firstX) <= Math.Abs(secondX) && Math.Abs(firstY) <= Math.Abs(secondY))
  47. {
  48. Console.Write($"({firstX}, {firstY})");
  49. Console.WriteLine($"({secondX}, {secondY})");
  50. }
  51. else
  52. {
  53. Console.Write($"({secondX}, {secondY})");
  54. Console.WriteLine($"({firstX}, {firstY})");
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement