|
|
вернуться в форумPlz. give inputs for test#1 Послано logic 3 сен 2008 20:23 got WA for test#1. Plz. help me. #include<stdio.h> float power(float i,float j) { float l,sum = 1; if (i == 0) return 0; if (j == 0) return 1; for(l = 1;l<= j;l++) sum = (sum * i); return (sum); } int main() { int N,i,j; float x[110],y[110],R, sum = 0,pi=3.14159265358979323846; float b[110]; scanf("%d",&N); scanf("%f",&R); for (i=0;i<N;i++) { scanf("%f %f",&x[i],&y[i]); } j = 1; for (i=0;i<N;i++) { if (i == (N-1)) { b[i] = sqrt((power(fabs((x[0]) - (x[i])),2)) + (power(fabs((y[0]) - (y[i])),2))); } else { b[i] = sqrt((power(fabs((x[i+1]) - (x[i])),2))+ (power(fabs((y[i+1]) - (y[i])),2))); } } for (i = 0;i<N;i++) { sum = sum + b[i]; } sum = sum + (2*pi*R); printf("%.2f",sum); return 0; } Edited by author 03.09.2008 20:29 Edited by author 03.09.2008 20:34 |
|
|