Написать подпрограмму нахождения расстояния между двумя точками, заданными своими координатами — Pascal(Паскаль)

program PascalGuru;

type
  xy = record
    x: real;
    y: real;
  end;

var
  n, i: integer;
  t: array [1 .. 3] of xy;
  rastAB, rastAC, rastBC: real;

procedure min(ab, ac, bc: real);
var
  min: real;
  ms: string;
begin
  min := ab;
  ms := 'Min(AB)=';
  if acthen begin min := ac;
    ms := 'Min(AC)=';
end;
if bcthen begin min := bc;
  ms := 'Min(BC)=';
end;
writeln(ms, min:0:2);
end;

function rastoyanie(ax, ay, bx, by: real): real;
begin
  rastoyanie := sqrt(sqr(bx - ax) + sqr(by - ay));
end;

begin
  write('Vvedite koordinaty tociki A: ');
  readln(t[1].x, t[1].y);
  write('Vvedite koordinaty tociki B: ');
  readln(t[2].x, t[2].y);
  write('Vvedite koordinaty tociki C: ');
  readln(t[3].x, t[3].y);

  writeln;
  writeln('Vy vveli:');
  writeln('A(', t[1].x:0:2, ',', t[1].y:0:2, ')');
  writeln('B(', t[2].x:0:2, ',', t[2].y:0:2, ')');
  writeln('C(', t[3].x:0:2, ',', t[3].y:0:2, ')');

  rastAB := rastoyanie(t[1].x, t[1].y, t[2].x, t[2].y);
  rastAC := rastoyanie(t[1].x, t[1].y, t[3].x, t[3].y);
  rastBC := rastoyanie(t[2].x, t[2].y, t[3].x, t[3].y);

  writeln;
  writeln('L(AB)= ', rastAB:0:2);
  writeln('L(AC)= ', rastAC:0:2);
  writeln('L(BC)= ', rastBC:0:2);

  writeln;
  min(rastAB, rastAC, rastBC);

  readln;

end.

Leave a Comment

88 − 86 =