| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
再次通知,小心数组范围!附代码#include<stdio.h>
#include<math.h>
#define N 100
#define PI 3.141592653589
struct point
{
double a, b;
};
double distance(struct point s, struct point t)
{
return sqrt(pow(s.a-t.a, 2) + pow(s.b-t.b, 2));
}
int main()
{
int M, i;
double redium;
struct point value[N];
double sum;
while (fscanf(stdin, "%d %lf", &M, &redium) != EOF)
{
sum = 2 * PI * redium;
fscanf(stdin, "%lf %lf", &value[0].a, &value[0].b);
for (i=1; i<M; i++)
{
fscanf(stdin, "%lf %lf", &value[i].a, &value[i].b);
sum += distance(value[i], value[i-1]);
}
sum += distance(value[i-1], value[0]);
printf("%.2lf\n", sum);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator