|
|
вернуться в форумWhy I got CE plz help #include <stdio.h> #include <math.h> double x[101],y[101]; int n=0; double len=0,rad=0,pi=2*acos(0); double dist(int n1,int n2) { double d1,d2;
if(x[n1]>=x[n2]) d1=x[n1]-x[n2]; if(y[n1]>=y[n2]) d2=y[n1]-y[n2]; if(x[n2]>=x[n1]) d1=x[n2]-x[n1]; if(y[n2]>=y[n1]) d2=y[n2]-y[n1];
if(d1==0)return d2; if(d2==0)return d1;
return sqrt((d1*d1)+(d2*d2)); } int main() { int i; scanf("%d %lf",&n,&rad);
for(i=1;i<=n;i++) { scanf("%lf %lf",&x[i],&y[i]); }
for(i=1;i<n;i++) { len = len+dist(i,i+1); }
len = len+dist(1,n); len = len+(2*pi*rad);
printf("%.2lf",len);
return 0; } Enter a valid email when submitting, and you'll get a report with compiler messages (+) Also, please read FAQ before asking anything else here ;) |
|
|