Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- // Write an expression that checks for given point (x, y) if it is within the circle K({1, 1}, 1.5)
- // and out of the rectangle R(top=1, left=-1, width=6, height=2).
- class PointInACircleOutOfARect
- {
- static void Main()
- {
- Console.WriteLine();
- Console.Write("Enter a value for x: ");
- double x = double.Parse(Console.ReadLine());
- Console.WriteLine();
- Console.Write("Enter a value for y: ");
- double y = double.Parse(Console.ReadLine());
- Console.WriteLine();
- double h = 1;
- double k = 1;
- double r = 1.5;
- if (((x - h) * (x - h) + (y - k) * (y - k)) <= (r * r))
- {
- Console.WriteLine(((x > 5) || (x < -1) || (y > 1) || (y < -1)) ? "YES" : "NO");
- Console.WriteLine();
- }
- else
- {
- Console.WriteLine("NO");
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement