[ create a new paste ] login | about

Link: http://codepad.org/P70BTW5p    [ raw code | output | fork ]

C++, pasted on Jan 7:
#include <stdio.h>
#include <stdlib.h>
#define N 1000

struct arrow2D{
 double x, y;
}yumiya[1000];

void set_arrow ( arrow2D* z )
{
 z->y = rand()/(double)RAND_MAX*2.0-1.0;
 z->x = rand()/(double)RAND_MAX*2.0-1.0;
}
int det_arrow(arrow2D* z)
{
	if((z->x)*(z->x)+(z->y)*(z->y)<=1){
		return 0;
	}else{
		return 1;
	}
}
double probabi(int t,int u)
{
	int a,b;
	a=b=0;

	a=t;
	b=u;

	return double(a/(a+b));

}


 int main(void)
{
	int i, n=0, h=0;

	for(i=0;i<N;i++){
		n+=det_arrow(yumiya[i]);
	}

	h=N-n;

	printf("%lf",probabi(n,h));
	return 0;
}


Output:
1
2
3
In function 'int main()':
Line 40: error: cannot convert 'arrow2D' to 'arrow2D*' for argument '1' to 'int det_arrow(arrow2D*)'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: