Stuck at test 3
Posted by
maple 3 May 2013 18:12
Unable to clear test3.
please help
#include<stdio.h>
#include<math.h>
int main()
{
float r;
float sum=0.0;
int i,n,nxt=0;
scanf("%d %f",&n,&r);
float dim[n][2];
for(i=0; i<n;i++)
{
scanf("%f%f",&dim[i][0],&dim[i][1]);
}
for(i=0;i<n;i++)
{
if(i+1==n)
nxt=n;
else nxt=i+1;
float y=pow((dim[i][0]-dim[nxt][0]),2);
float z=pow((dim[i][1]-dim[nxt][1]),2);
y=y+z;
sum+=sqrt(y);
}
sum+=2*3.14159*r;
printf("%.02f\n",sum);
return 0;
}