|
|
вернуться в форумC++ Code - Can't find what is wrong in it ! Help Please ! Послано Sylap 18 авг 2012 05:17 //1020. Rope # include <cstdio> # include <cmath> # include <iomanip> # include <iostream> using namespace std; struct dbl{double x,y;}; int n,r; dbl p[110]; double res; int main() { cin>>n>>r; for(int i=0;i<n;i++) cin>>p[i].x>>p[i].y; for(int i=1;i<n;i++) res+=sqrt( (p[i].x-p[i-1].x)*(p[i].x-p[i-1].x) + (p[i].y-p[i-1].y)*(p[i].y-p[i-1].y) ); res+=sqrt( (p[0].x-p[n-1].x)*(p[0].x-p[n-1].x) + (p[0].y-p[n-1].y)*(p[0].y-p[n-1].y) ); res+=2*r*acos(-1.0); printf("%.2lf",res); return 0; } Can you please tell me what is wrong in it? Edited by author 18.08.2012 05:19 Edited by author 19.08.2012 20:03 Re: C++ Code - Can't find what is wrong in it ! Help Please ! You get 2*PI*r when n is 1~ Try the case 1 1! Edited by author 29.08.2012 15:41 Edited by author 29.08.2012 15:41 |
|
|