There are set K circles (the abscissa and the horde of the center and radius) and m (m<=20) points (abscissa and ordin) are set. write a program to determine how many circles each point lies in.
But I have errors and I don't know how to solve them.
<
#include<iostream>
#include<stdlib.h>
#include<conio.h>
using namespace std;
int main() {
system("chcp 1251");
int k; //Circle numbers
int m; //Point numbers
float x[20], y[20],
X[20], Y[20],
R[10];
cout << "Number of points:"; cin >> k;
for (int i = 0; i < k; i++)
{
cout << i << "-Circle: \n";
cout << "X:"; cin >> X[i];
cout << "Y:"; cin >> Y[i];
cout << "R:"; cin >> R[i];
}
//Въвеждане на данните а точките
for (int j = 0; j < 20; j++) {
cout << j << "-point:\n";
cout << "x:"; cin >> x[j];
cout << "y:"; cin >> y[j];
}
int Br[20]; //Number of circles
for (int j = 0; j < m; j++)
{
Br[i] = 0;
for (int i = 0; i < k; i++)
if (pow(x[j] - X[i], 2) + pow(y[j] - Y[i], 2) <= pow(R[i], 2)) Br[i]++;
}
//Result - Number of Circles
for (int i = 0; i < m; i++) cout << Br[i] << endl;
getch();
}
>
#include<iostream>
#include<stdlib.h>
#include <conio.h>
usingnamespace std;
int main() {
system("chcp 1251");
int k,//-Number of circles
m;//- Number of points
float x[20], y[20],
X[10], Y[10],
R[10];
//Enter circles data
cout << "Number of circles:"; cin >> k;
for (int i = 0; i < k; i++) {
cout << i << "-of Circle: \n";
cout << "-the abc of the center:"; cin >> X[i];
cout << "-the horde of the center:"; cin >> Y[i];
cout << "-the radius of the circumference:"; cin >> R[i];
}
//Entering points data
cout << "Number of points:"; cin >> m;
for (int j = 0; j < m; j++) {
cout << j << "-Point:\n";
cout << "-the abscissa of the point:"; cin >> x[j];
cout << "-the horde of the point:"; cin >> y[j];
}
int br[10];
for (int i = 0; i < m; i++) {
br[i] = 0;
for (int j = 0; j < m; j++)
if (pow(x[j] - X[i], 2) + pow(y[j] - Y[i], 2) <= pow(R[i], 2)) br[i]++;
}
//Results
for (int i = 0; i < m; i++) cout << br[i] << endl;
//getch();
}
for( int i = 0 ; i < num_points ; ++i ) // for each point (outer loop)
{
int cnt = 0 ; // count of how many circles this point lies in
for( int j = 0 ; j < num_circles ; ++j ) // for each circle (inner loop)
{
// increment cnt if point #i lies in circle #j
if( point_#i_lies_in_circle_#j ) ++cnt ; // pseudocode
}
print x, y, cnt // pseudocode
}