N
N
nimbus2142021-09-28 13:16:12
Mathematics
nimbus214, 2021-09-28 13:16:12

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.6152eb6329b9d510886120.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexandroppolus, 2021-09-28
@nimbus214

"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);
}

W
Wataru, 2021-09-28
@wataru

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 question

Ask a Question

731 491 924 answers to any question