#include
#include
#include
#define N_MAX_PUNTI 1000000
#define STRLEN 1024
#define FILE_PATH "./filetxt/cerchi.txt"
#define MAX(A,B) ((A)>(B))?A:B
#define MIN(A,B) ((A)<(B))?A:B
#define ABS(A) ((A)<0)?(-A):A
typedef struct _dot {
float x;
float y;
} dot;
typedef struct _circ {
dot centro;
float r;
} circ;
typedef dot* pdot;
typedef circ* pcirc;
typedef FILE* pfile;
float frandminmax(float min, float max)
{
return ((((float)rand())/RAND_MAX)*(max-min))+min;
}
int main(void)
{
unsigned i,i_mc,n_cerchi,n_hit,check;
float x_min,x_max,y_min,y_max,x_min_mc,x_max_mc,y_min_mc,y_max_mc,r_grande,r_gq,a,b,c,area;
char s[STRLEN];
dot baricentro,test;
pcirc pcerchio,pc,pc_max;
pfile pf;
srand(time(NULL));
if ((pf=fopen(FILE_PATH,"r"))==NULL) goto err_file;
fscanf(pf,"%s",s);
n_cerchi=atoi(s);
if ((pcerchio=(pcirc)malloc(sizeof(circ)*n_cerchi))==NULL) goto err_mem;
baricentro.x=baricentro.y=0;
for (i=0;icentro.x;
b=test.y-pc->centro.y;
c=pc->r;
if ((a*a+b*b)<(c*c)) {
n_hit++;
check=0;
}
pc++;
} while ((pc