GerganaTsirkova

CenterPoint

Dec 1st, 2017
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 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 CenterPoint
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double x1 = double.Parse(Console.ReadLine());
  14. double x2 = double.Parse(Console.ReadLine());
  15. double y1 = double.Parse(Console.ReadLine());
  16. double y2 = double.Parse(Console.ReadLine());
  17.  
  18. ClosestPoint(x1, x2, y1, y2);
  19. }
  20.  
  21. private static void ClosestPoint(double x1, double x2, double y1, double y2)
  22. {
  23. if((x1==y1) && (x2==y2))
  24. Console.WriteLine("({0}, {1})",x1,y1);
  25. else
  26. {
  27. double distance1 = Math.Sqrt(x1 * x1 + x2 * x2);
  28. double distance2 = Math.Sqrt(y1 * y1 + y2 * y2);
  29. if(distance1<distance2)
  30. Console.WriteLine("({0}, {1})",x1,x2);
  31. else
  32. Console.WriteLine("({0}, {1})", y1, y2);
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment