Hey :D

I want to write a code that that is going to read the coordinates and the coverage radius of the base station and then coordinates of n people.Then I want to find how many of these people are in the coverage of the base station.
I wrote this code,but I can't get the result..Can anybody help me improve something on this code..

#include <iostream>
#include <math.h>
using namespace std;

int main ()
{
float x,y,r,a,b,distance;
int n;
cin >> n >> x >> y >> r;
int cnt=0;
for (;cnt<=n;cnt++)
{
cin >> a >> b;
distance=(((b-y)*(b-y))+((a-x)*(a-x)));
if (distance<=r)
cout << " " << n;
}
return 0;
}
You would have to compare distance to r^2 as you have not rooted the result.
Topic archived. No new replies allowed.