Answer the question
In order to leave comments, you need to log in
How to find whether a point belongs to such a graph?
It is necessary to write a program on the pluses to find whether a point belongs to a graph.
Answer the question
In order to leave comments, you need to log in
"Graph" in your terminology - a gray area? If yes, then it's just a set of ifs
if (y > 0) {
return (y >= x) && (y*y + x*x <= 9);
} else {
return (y >= -3) && (x <= 3) && (x >= -3) && !(y < -1 && y > -2 && x < -1 && x > -2);
}
Break the area into simple shapes (squares, circles, half-planes) and describe logically. Like a point in the area, if it is in figure A, but not figure B; or in figures C and D, or in figures E and E.
Further to translate this into code is one if with a bunch of conditions combined with logical or ( ||
) or logical AND ( &&
).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question