- 绕钉子的长绳子
- 2015-12-05 01:25:39 @
#include<stdio.h>
#include<math.h>
int main(void)
{
int n, r;
scanf("%d%d", &n, &r);
float point[n][2];
for(int i = 0; i <= n-1; i ++)
scanf("%f%f", &point[i][0], &point[i][1]);
float output = 0;
for(int i = 1; i <= n-1; i ++)
output = sqrt( (point[i][0]-point[i+1][0])*(point[i][0]-point[i+1][0]) + (point[i][1]-point[i+1][1])*(point[i][1]-point[i+1][1]) )+ output;
output = output + sqrt( (point[n-1][0]-point[0][0])*(point[n-1][0]-point[0][0]) + (point[n-1][1]-point[0][1])*(point[n-1][1]-point[0][1]) );
output = output + 2*acos(-1)*r;
printf("%.2f", output);
return 0;
}
TO 半夜一起刷题的某个男人:
不准说我脸黑。。。。。。
2 条评论
-
twd2 LV 9 MOD @ 2015-12-05 03:01:31
'for' loop initial declarations are only allowed in C99 mode
-
2015-12-05 01:30:28@
###你的姿势不正确,请按照基本法提交
#include<stdio.h>
#include<math.h>
int main()
{
int n, r;
scanf("%d%d", &n, &r);
float point[n][2];
for(int i = 0; i <= n-1; i ++)
scanf("%f%f", &point[i][0], &point[i][1]);
float output = 0;
for(int i = 1; i <= n-1; i ++)
output = sqrt( (point[i][0]-point[i+1][0])*(point[i][0]-point[i+1][0]) + (point[i][1]-point[i+1][1])*(point[i][1]-point[i+1][1]) )+ output;output = output + sqrt( (point[n-1][0]-point[0][0])*(point[n-1][0]-point[0][0]) + (point[n-1][1]-point[0][1])*(point[n-1][1]-point[0][1]) );
output = output + 2*acos(-1)*r;
printf("%.2f", output);
return 0;
}
- 1