Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace PointInCercleAndRectangle
- {
- class PointInCercleRectangle
- {
- static void Main()
- { //Напишете програма, която проверява дали дадена точка, с кординати (х,у) се намира във вътрешността на окръжност с център (0, 0)
- // и радиус 5 и в същото време вътре в правоъгълник с кординати (-1, 2) (5, 5).
- //Кординатите на правоъгълника са съответно: долен ляв и горен десен ъгъл.
- bool inCircle, inRectangle;
- Console.Write("Enter a value for x: ");
- double x = double.Parse(Console.ReadLine());
- Console.Write("Enter a value for y: ");
- double y = double.Parse(Console.ReadLine());
- inCircle = (Math.Sqrt(x * x + y * y)) <= 5; // check if x,y are within the circle
- inRectangle = ((-1 <= x) && (x <= 5)) && ((2 <= y) && (y <= 5)); // check if x,y are within the rectangle
- bool inCircleAndRectangle = inCircle && inRectangle; // chek if x,y are within the rectangle and circle
- Console.WriteLine("The point with coortinats ({0};{1}) is within the circle and the rectangle? (true/false):{2}",x,y,inCircleAndRectangle) ;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement