Дан файл вещественных чисел. Найти его последний локальный максимум — Pascal(Паскаль)

program file18;

var
  F: File of real;
  S: String;
  Max, V1, V2, V3: real;
  I: Integer;

begin
  Write('File: ');
  ReadLn(S);
  Assign(F, S);
  Reset(F);
  Read(F, V1);
  WriteLn(V1:6:3);
  Read(F, V2);
  WriteLn(V2:6:3);
  if V1 > V2 then
    Max := V1
  else if V1 <> V2 then
    Max := V2;
  while not Eof(F) do
  begin
    Read(F, V3);
    WriteLn(V3:6:3);
    if (V3 > V1) and (V3 > V2) then
      Max := V3
    else if (V1 > V2) then
      Max := V1
    else if (V2 <> V1) then
      Max := V2;
    V1 := V2;
    V2 := V3;
  end;
  WriteLn('Local maximum: ', Max:6:3);
  ReadLn;
end
..

Leave a Comment

42 − 37 =