Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class CircleAndRectangle
- {
- static void Main()
- {
- Console.WriteLine("Enter X & Y coordinates that have to be in the circle K((1,1)3)\r\nand out of the rectangle R(top=1; left= -1; width = 6; heigh = 2):");
- Console.Write("x = ");
- string first = Console.ReadLine();
- int x = int.Parse(first);
- Console.Write("y = ");
- string second = Console.ReadLine();
- int y = int.Parse(second);
- int cirleRadius = 3;
- bool inCircle = (x * x + y * y <= cirleRadius * cirleRadius);
- bool rx = (x >= (-1)) && (x <= 5);
- bool ry = (y>=(-1)) && (y<=1);
- bool inRectangle = (rx == true) && (ry == true);
- bool outRectangle = (rx ==true) || (ry==true);
- if (((inCircle == true) && (inRectangle == true)) || (outRectangle == false))
- {
- Console.WriteLine("Coordinates that you entered are not valide!");
- }
- else if ((inCircle == true) && (outRectangle == true))
- {
- Console.WriteLine("ok");
- }
- else
- {
- Console.WriteLine("Error!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement