Вывести на экран записи которые хранятся в файле, начиная с последней записи и заканчивая первой — Pascal(Паскаль)

uses crt;
const n=4;
type rec=record
      name:string;
      tovar:string;
      st:real;
     end;
var x:array[1..n] of rec;
    i:integer;
    f:file of rec;
begin
ClrScr;
Assign(f,'rec.txt');
{$I-}
Rewrite(f);
{$I+}
for i:=1 to n do
 begin
  Write(' Name: ');
  Readln(x[i].name);
  Write(' Tovar: ');
  Readln(x[i].tovar);
  Write(' Stoimost: ');
  Readln(x[i].st);
 end;
for i:=1 to n do
 Write(f,x[i]);
close(f);
Reset(f);
while not eof(f) do
 Read(f,x[n]);
Writeln('Table: ');
Writeln('--------------------------------');
Writeln('||  Name  |  Tovar  |  Stoim  ||');
Writeln('--------------------------------');
for i:=n downto 1 do
 Writeln('||',x[i].name:8,'|',x[i].tovar:9,'|',x[i].st:9:2,'||');
Writeln('--------------------------------');
close(f);
Readln;
end.

Leave a Comment

− 2 = 1