NOIP普及组第三题结果很奇怪这是我的程序program missile;varx:array[1..10000]of integer;y:array[1..10000]of integer;a,b,i,n,x1,y1,x2,y2:integer;m1,m2,mincost:real;beginread(x1,y1,x2,y2);read(n);for i:=1 to n dobeginread(x[i],y[i]);end;m
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 19:14:32
NOIP普及组第三题结果很奇怪这是我的程序program missile;varx:array[1..10000]of integer;y:array[1..10000]of integer;a,b,i,n,x1,y1,x2,y2:integer;m1,m2,mincost:real;beginread(x1,y1,x2,y2);read(n);for i:=1 to n dobeginread(x[i],y[i]);end;m
NOIP普及组第三题结果很奇怪
这是我的程序
program missile;
var
x:array[1..10000]of integer;
y:array[1..10000]of integer;
a,b,i,n,x1,y1,x2,y2:integer;
m1,m2,mincost:real;
begin
read(x1,y1,x2,y2);
read(n);
for i:=1 to n do
begin
read(x[i],y[i]);
end;
m1:=0;m2:=0;
for a:=1 to n do
begin
if (x[a]>x1) and(x1>x2) and ((sqrt(sqr(x[a]-x1)+sqr(y[a]-y1)))>m1)
then
m1:=sqrt(sqr(x[a]-x1)+sqr(y[a]-y1));
if (x[a]x2) and ((sqrt(sqr(x[a]-x2)+sqr(y[a]-y2)))>m2)
then
m2:=sqrt(sqr(x[a]-x1)+sqr(y[a]-y2));
if (x[a]>x2) and(x1m1)
then
m1:=sqrt(sqr(x[a]-x2)+sqr(y[a]-y2));
if (x[a]x2) and ((sqrt(sqr(x[b]-x1)+sqr(y[b]-y1)))>m1) and ((sqrt(sqr(x[b]-x2)+sqr(y[b]-y2)))>m2)
then
m1:=sqrt(sqr(x[b]-x1)+sqr(y[b]-y1));
m2:=sqrt(sqr(x[b]-x2)+sqr(y[b]-y2));
if ((x1m1) and ((sqrt(sqr(x[b]-x1)+sqr(y[b]-y1)))>m2))
then
m1:=sqrt(sqr(x[b]-x2)+sqr(y[b]-y2));
m2:=sqrt(sqr(x[b]-x1)+sqr(y[b]-y1));
end;
mincost:=(sqr(m1)+sqr(m2));
writeln(mincost);
end.为什么输出的是 1.0000000e+001?
NOIP普及组第三题结果很奇怪这是我的程序program missile;varx:array[1..10000]of integer;y:array[1..10000]of integer;a,b,i,n,x1,y1,x2,y2:integer;m1,m2,mincost:real;beginread(x1,y1,x2,y2);read(n);for i:=1 to n dobeginread(x[i],y[i]);end;m
因为你定义的mincost是real类型- -