0_0_27832541_31326.cpp: In function 'int sign(double)':
0_0_27832541_31326.cpp:16:15: error: a function-definition is not allowed here before '{' token
int main(void){ double a,b,c,r; srand(time(0)); while((scanf("%lf%lf%lf%lf",&a,&b,&c,&r))==4){ if(!a && !b && !c && !r) break; int n=3; p[0]=Point(0,0); p[1]=Point(a,0); double x=(a*a+c*c-b*b)/2/a; double y=sqrt(c*c-x*x); p[2]=Point(x,y);// for(int i=0;i<3;i++) printf("%f %f\n",p[i].x,p[i].y); double sx=0.0,sy=0.0; double E=0.0; double T=100; for(int i=0;i<n;i++) E+=CulArea(p[i],p[(i+1)%n],Circle({sx,sy},r));// cout << E << endl; while(T>EPS){ double mx=0.0; double nextx,nexty; for(int i=0;i<100;i++){ double ang=2*PI*myrand(); double nx=sx+cos(ang)*T; double ny=sy+sin(ang)*T; double nE=0; for(int i=0;i<n;i++) nE+=CulArea(p[i],p[(i+1)%n],Circle({nx,ny},r)); if(nE>mx){ mx=nE; nextx=nx; nexty=ny; } } if(sign(mx-E)>0 || exp(mx-E)/T>myrand()){ E=mx; sx=nextx; sy=nexty; } T*=0.8; } printf("%.2f\n",E); } return 0;}
^
0_0_27832541_31326.cpp:16:299: error: expected '}' at end of input
int main(void){ double a,b,c,r; srand(time(0)); while((scanf("%lf%lf%lf%lf",&a,&b,&c,&r))==4){ if(!a && !b && !c && !r) break; int n=3; p[0]=Point(0,0); p[1]=Point(a,0); double x=(a*a+c*c-b*b)/2/a; double y=sqrt(c*c-x*x); p[2]=Point(x,y);// for(int i=0;i<3;i++) printf("%f %f\n",p[i].x,p[i].y); double sx=0.0,sy=0.0; double E=0.0; double T=100; for(int i=0;i<n;i++) E+=CulArea(p[i],p[(i+1)%n],Circle({sx,sy},r));// cout << E << endl; while(T>EPS){ double mx=0.0; double nextx,nexty; for(int i=0;i<100;i++){ double ang=2*PI*myrand(); double nx=sx+cos(ang)*T; double ny=sy+sin(ang)*T; double nE=0; for(int i=0;i<n;i++) nE+=CulArea(p[i],p[(i+1)%n],Circle({nx,ny},r)); if(nE>mx){ mx=nE; nextx=nx; nexty=ny; } } if(sign(mx-E)>0 || exp(mx-E)/T>myrand()){ E=mx; sx=nextx; sy=nexty; } T*=0.8; } printf("%.2f\n",E); } return 0;}
^
|