|
|
вернуться в форумI soon started to use C++ and I don't know why comperror???Please.... #include <stdio.h> #include <math.h> void main(){ double r,a,s,angl,cosa; scanf("%lf %lf",&a,&r); if (2*r<a) s=M_PI*r*r; else if (sqrt(2)*r>a) s=a*a; else{ cosa=a/(2*r); angl=2*acos(cosa); angl=M_PI/2-angl; s=((a/2)*sqrt(r*r-(a*a)/4))+angl*r*r/2; } printf("%.3lf\n",4*s); } I think that the problem is in M_PI........ Maybe their compiler doesn't support this constant, or at least it has a different name > #include <stdio.h> > #include <math.h> > void main(){ > double r,a,s,angl,cosa; > scanf("%lf %lf",&a,&r); > if (2*r<a) s=M_PI*r*r; > else if (sqrt(2)*r>a) s=a*a; > else{ > cosa=a/(2*r); > angl=2*acos(cosa); > angl=M_PI/2-angl; > s=((a/2)*sqrt(r*r-(a*a)/4))+angl*r*r/2; > } > printf("%.3lf\n",4*s); > } Re: I soon started to use C++ and I don't know why comperror???Please.... Послано - GO - 21 окт 2005 13:39 i think my reply was too late. but for other people. when using sqrt(2) or something which arguments are not integer, you should use -> sqrt(2.0) instead. Re: I soon started to use C++ and I don't know why comperror???Please.... sqrt(2) ==> sqrt(2.0) Thank you very much!!! I'd reciiving :"compilation error"... But now all O.K.! )) |
|
|