Даны координаты двух точек. Определить, какую из осей пересекает отрезок, соединяющий эти две точки — Pascal(Паскаль)

program hr;

var
  x1, y1, x2, y2: real;
  da: boolean;

begin
  write('Vvedite X1 dlia tociki A: ');
  readln(x1);
  write('Vvedite Y1 dlia tociki A: ');
  readln(y1);

  write('Vvedite X2 dlia tociki B: ');
  readln(x2);
  write('Vvedite Y2 dlia tociki B: ');
  readln(y2);

  writeln;
  writeln('A(', x1:0:2, ',', y1:0:2, ') & ', 'B(', x2:0:2, ',', y2:0:2, ')');
  writeln;
  da := false;
  if (x1 > 0) and (y1 > 0) and (x2 < 0) and (y2 > 0) then
  begin
    writeln('peresekaet osi "OY"');
    da := true;
  end;
  if (x1 > 0) and (y1 > 0) and (x2 < 0) and (y2 < 0) then
  begin
    writeln('peresekaet osi "XY"');
    da := true;
  end;
  if (x1 > 0) and (y1 > 0) and (x2 > 0) and (y2 < 0) then
  begin
    writeln('peresekaet osi "OX"');
    da := true;
  end;
  if (x1 < 0) and (y1 > 0) and (x2 < 0) and (y2 < 0) then
  begin
    writeln('peresekaet osi "OX"');
    da := true;
  end;
  if (x1 < 0) and (y1 > 0) and (x2 > 0) and (y2 < 0) then
  begin
    writeln('peresekaet osi "XY"');
    da := true;
  end;
  if (x1 < 0) and (y1 < 0) and (x2 > 0) and (y2 < 0) then
  begin
    writeln('peresekaet osi "OY"');
    da := true;
  end;

  if (x1 < 0) and (y1 > 0) and (x2 > 0) and (y2 > 0) then
  begin
    writeln('peresekaet osi "OY"');
    da := true;
  end;
  if (x1 < 0) and (y1 < 0) and (x2 > 0) and (y2 > 0) then
  begin
    writeln('peresekaet osi "XY"');
    da := true;
  end;
  if (x1 > 0) and (y1 < 0) and (x2 > 0) and (y2 > 0) then
  begin
    writeln('peresekaet osi "OX"');
    da := true;
  end;
  if (x1 < 0) and (y1 < 0) and (x2 < 0) and (y2 > 0) then
  begin
    writeln('peresekaet osi "OX"');
    da := true;
  end;
  if (x1 > 0) and (y1 < 0) and (x2 < 0) and (y2 > 0) then
  begin
    writeln('peresekaet osi "XY"');
    da := true;
  end;
  if (x1 > 0) and (y1 < 0) and (x2 < 0) and (y2 < 0) then
  begin
    writeln('peresekaet osi "OY"');
    da := true;
  end;

  if not da then
    writeln('Eti tociki ne peresekaiyt ni odny osi');

  readln;

end.

Leave a Comment

− 8 = 1