|
|
вернуться в форумWhy wrong answer? #include <stdio.h> #include <stdlib.h> #include <math.h> /* * */ int main(int argc, char** argv) { /*dataseg*/ int N; int R; int i; float *x; float *y; float length = 0; double PI = 2.0*acos(0.0);
scanf("%d", &N); scanf("%d", &R); x = (float *) malloc(N * sizeof (float)); y = (float *) malloc(N * sizeof (float)); for (i = 0; i < N; i++) { scanf("%f", &x[i]); scanf("%f", &y[i]); } for (i = 0; i < N - 1; i++) { length += sqrt(pow(x[i + 1] - x[i], 2) + pow(y[i + 1] - y[i], 2)); } length += sqrt(pow(x[N - 1] - x[0], 2) + pow(y[N - 1] - y[0], 2)); length += 2 * PI * R; printf("%.2f", length); free(x); free(y); return (0); } Re: Why wrong answer? Послано melkiy 3 мар 2009 17:37 Maybe because R must be real, not integer. |
|
|