The next sample exam problem is about checking whether given point stays inside or outside given figure (see the image below).
Watch the video lesson about solving the "Point in a Figure" problem: https://youtu.be/SzxHyZVdhEo.
Write a program that checks whether a point (with coordinates x and y) is inside or outside the following figure:
The console reads two integers (one per line): x and y.
All input numbers are integers in the range [-1000 … 1000].
Print on the console "in" or "out" – whether the point is inside or outside the figure (the outline is inside).
To find out if the point is in the figure, we will divide the figure into 2 rectangles:
A sufficient condition is the point to be located in one of them, in order to be in the figure.
We read the input data from the console:
We will initialize two variables that will mark whether the point is in one of the rectangles.
When printing the message, we will check whether any of the variables has accepted a value of
true. It is enough only one of them to be
true, so that the point is in the figure.
Test your solution here: https://judge.softuni.org/Contests/Practice/Index/516#3.