Advertisement
Guest User

Untitled

a guest
Jan 21st, 2015
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.             // 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).
  4.  
  5.             Console.WriteLine("Input x:");
  6.             double x = double.Parse(Console.ReadLine());
  7.             Console.WriteLine("Input y:");
  8.             double y = double.Parse(Console.ReadLine());
  9.             bool inCircle = ((x - 1) * (x - 1) + (y - 1) * (y - 1) <= 1.5 * 1.5);
  10.             Console.WriteLine(inCircle);
  11.             bool OutRectangle = (x<-1 || x>5) && (y<-1 || y>1);
  12.             Console.WriteLine(OutRectangle);
  13.  
  14.  
  15.          
  16.             if (inCircle == true && OutRectangle == true)
  17.             {
  18.                 Console.WriteLine("yes");
  19.             }
  20.             else
  21.             {
  22.                 Console.WriteLine("no");
  23.             }
  24.  
  25.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement