Advertisement
TodorovH

PointInACircleOutOfARect

Mar 19th, 2014
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. using System;
  2.  
  3. // Write an expression that checks for given point (x, y) if it is within the circle K({1, 1}, 1.5)
  4. // and out of the rectangle R(top=1, left=-1, width=6, height=2).
  5.  
  6. class PointInACircleOutOfARect
  7. {
  8. static void Main()
  9. {
  10. Console.WriteLine();
  11. Console.Write("Enter a value for x: ");
  12. double x = double.Parse(Console.ReadLine());
  13. Console.WriteLine();
  14. Console.Write("Enter a value for y: ");
  15. double y = double.Parse(Console.ReadLine());
  16. Console.WriteLine();
  17. double h = 1;
  18. double k = 1;
  19. double r = 1.5;
  20. if (((x - h) * (x - h) + (y - k) * (y - k)) <= (r * r))
  21. {
  22. Console.WriteLine(((x > 5) || (x < -1) || (y > 1) || (y < -1)) ? "YES" : "NO");
  23. Console.WriteLine();
  24. }
  25. else
  26. {
  27. Console.WriteLine("NO");
  28. Console.WriteLine();
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement