Const n=4; type point=record x,y:real; end; var m:array[1..n] of point; i,j:integer; min:real; function r(p1,p2:point):real; begin r:=sqr(p1.x-p2.x)+sqr(p1.y-p2.y); end; begin Randomize; for i:=1 to n do begin write(i,' точка: '); readln(m[i].x, m[i].y); end; min:=100000; for i:=1 to n-1 do for j:=i+1 to n do if r(m[i],m[j])<min then min:=r(m[i],m[j]); writeln('min=',sqrt(min)); end.
Answers & Comments
Verified answer
Const n=4;type point=record
x,y:real;
end;
var m:array[1..n] of point;
i,j:integer; min:real;
function r(p1,p2:point):real;
begin
r:=sqr(p1.x-p2.x)+sqr(p1.y-p2.y);
end;
begin
Randomize;
for i:=1 to n do
begin
write(i,' точка: '); readln(m[i].x, m[i].y);
end;
min:=100000;
for i:=1 to n-1 do
for j:=i+1 to n do
if r(m[i],m[j])<min then min:=r(m[i],m[j]);
writeln('min=',sqrt(min));
end.
Пример:
1 точка: 1 1
2 точка: 5 1
3 точка: 1 4
4 точка: 5 4
min=3