Circular zones - instructions for solving the task

Area: binary search,  sorting arrayYou need 3 array: Given that the radius of concentric circles are not injected, than the width of the belts (circular rings), these radius should be calculated by adding the width of the liquid ring to the radius of the previous smaller circle, and then inserting this value into a series of radius (3).

Furthermore, using a binary search algorithm, look for a position in a series of radius, where the distance R from the center to the current point M (x, y)
 located in a belt that precedes the radius in a row at the examined position.
For example, if the distance from the center of the center R is calculated from the radius in a row at the current position with r [s], then finding the belt index where the point looks like:

if(R>r[s-1]  &&  R<=r[s])
{
foundRadius=true;
pos=s;
break;
}


Pre-check that the index s-1 has elements in the r sequence. If not, for example, s = 0, then the previous radius is zero.
The following code can solve this:

/*Specifies the previous radius*/
if(s-1<0)     //If it is with the initial index, then the smaller ring of the semicircle is equal to zero
  {
                rP=0;
    }
else{
                rP=r[s-1];
}​