不是VIP会员,不能显示答案

题目解答

题目:
program noi_003;
const n=7; m=6;
var i,j,x0,y0,x1,y1,x2,y2:integer;
d:real; p:boolean; g:array[0..n,0..m] of 0..1;

function disp(x1,y1,x2,y2:integer):real;
begin disp:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); end;

begin
for i:=0 to n do  for j:=0 to m do  g[i,j]:=0 ;
readln(x1,y1,x2,y2); g[x1,y1]:=1; g[x2,y2]:=1; p:=true;
while p do
begin
p:=false; d:=disp(x1,y1,x2,y2); x0:=x1; y0:=y1;
for i:=4 to n do for j:=0 to m do
if (d>disp(i,j,x2,y2))and(g[i,j]=0)then
begin d:=disp(i,j,x2,y2); x0:=i; y0:=j; end;
if(x0<>x1) or (y0<>y1) then
begin x1:=x0; y1:=y0; p:=true; g[x1,y1]:=1; end;
d:=disp(x1,y1,x2,y2); x0:=x2; y0:=y2;
for i:=0 to 3 do  for j:=0 to m do
if (d<disp(x1,y1,i,j)) and (g[i,j]=0) then
begin d:=disp(x1,y1,i,j); x0:=i; y0:=j end;
if(x0<>x2)or(y0<>y2) then
begin x2:=x0;y2:=y0;p:=true; g[x2,y2]:=1; end;
end; writeln(x1,y1,x2,y2)
end.
输入:7 6 0 0
输出:4302
考点:
分析:
解答:
评论:
老师: