为什么会这样

var n,r,i:integer;
    sum,x,x1,x2,y,y1,y2:real;
begin
  readln(n,r);
  sum:=2*r*pi;
  readln(x,y);
  x1:=x;
  y1:=y;
  for i:=1 to n-1 do begin
    readln(x2,y2);
    sum:=sum+sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    x1:=x2;
    y1:=y2;
  end;
  sum:=sum+sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
  writeln(sum:0:2);
end.

这样错了
pascal
var n,i:integer;
sum,r,x,x1,x2,y,y1,y2,t:real;
begin
readln(n,r);
sum:=2*r*pi;
readln(x,y);
x1:=x;
y1:=y;
for i:=1 to n-1 do begin
readln(x2,y2);
t:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
sum:=sum+t;
x1:=x2;
y1:=y2;
end;
t:=sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
sum:=sum+t;
writeln(sum:0:2);
end.

这样就对了?

1 条评论

  • @ 2016-03-13 00:27:42

    因为您在第一份代码中把r定义成了integer而非real

  • 1

信息

ID
1007
难度
5
分类
模拟 点击显示
标签
(无)
递交数
12262
已通过
4337
通过率
35%
被复制
29
上传者