All pastes #742902 Raw Edit

Something

public c v1 · immutable
·published 2007-10-19 22:24 UTC
rendered paste body
#include <stdio.h>#include <math.h>#include <stdlib.h>#include <time.h>#define PI 3.14159265358979323846double c = 3*100000000;double f = 2.44*1000000000;double lam;double result=0.0862;int length = 806;double attenFrii(double r);double mag(double x1,double y1,double x2,double y2);int main(){  unsigned int iseed = (unsigned int)time(NULL);  srand (iseed);  long unsigned int top =0;  long unsigned int bottom =0;  double xa,xb,xc,ya,yb,yc,Uab,Ubc,Uac;    int count = 1;  lam = c/f;  printf("%.14f\n",result);  while(1){        Uab = 40*((double) random() / (double) 0x7fffffff);    Uac = 40*((double) random() / (double) 0x7fffffff);    Ubc = 40*((double) random() / (double) 0x7fffffff);        xa = length*((double) random() / (double) 0x7fffffff);    ya = length*((double) random() / (double) 0x7fffffff);    xb = length*((double) random() / (double) 0x7fffffff);    yb = length*((double) random() / (double) 0x7fffffff);    xc = length*((double) random() / (double) 0x7fffffff);    yc = length*((double) random() / (double) 0x7fffffff);        /*if( (attenFrii(mag(xa,ya,xb,yb)) >= pow(10,(-90+Uab)/10))	&& (attenFrii(mag(xb,yb,xc,yc)) >= pow(10,(-90+Ubc)/10)))      {	top++;      }    if( (attenFrii(mag(xa,ya,xc,xc)) >= pow(10,(-90+Uac)/10)))      {	bottom++;	}*/    if( (attenFrii(mag(xa,ya,xb,yb)) >= pow(10,(-90+Uab)/10))	&& (attenFrii(mag(xb,yb,xc,yc)) >= pow(10,(-90+Ubc)/10)))      {	top++;	if( (attenFrii(mag(xa,ya,xc,xc)) >= pow(10,(-90+Uac)/10)))	  {	    bottom++;	  }      }        if(bottom!=0 && top!=0){      result = (((double)count*result)+((double)bottom/(double)top))/(count+1);}    if(count%1000000==0)      { 	printf("%.14f\n",result);	//printf("with %lu   %lu  \n",bottom,top);      }    count++;  }  return 0;}double attenFrii(double r){  return (pow(lam/(4*PI*r),2));} double mag(double x1,double y1,double x2,double y2){  return sqrt(pow(x1-x2,2)+pow(y1-y2,2));}