var

  t:array[1..3,1..3] of integer;
  i,j:byte;
  v:text;

  begin

  for i:=1 to 3 do
  for j:=1 to 3 do


  begin

  write('Enter elements [',i,',',j,'] ');
  readln(t[i,j]);
  end;
  assign(v,'output.txt');
  rewrite(v);
  for i:= 3 downto 1 do
  begin
  for j:= 1 to 3 do


  write(v, t[i,j], '  ' );
  writeln(v);
  end;
  close(v);

  end.

Problem is next. I need to change row right to left and i need to save entered numbers to "input.txt" and save reversed rows to "output.txt".
I have tried something and then crashes pascal or i get blank txt file.

(*
Problem is next. I need to change row right to left
and i need to save entered numbers to "input.txt"
and save reversed rows to "output.txt".
I have tried something and then crashes pascal or i get blank txt file.
*)

program sol01;
uses crt;
var  t:array[1..3,1..3] of integer;
     i,j:byte;
     fi,fo:file of integer;
     temp:integer;

begin
  assign(fi,'input.txt');
  assign(fo,'output.txt');
  rewrite(fi);
  rewrite(fo);

  (*gathering data,and writting them to input.txt *)
  for i:=1 to 3 do begin
      for j:=1 to 3 do  begin
          write('Enter elements [',i,',',j,'] : ');
          readln(t[i,j]);
          write(fi,t[i,j]);
      end;
  end;
  reset(fi);
  (*read back fi (input.txt)*)
  write('contents of input.txt:  ');
  while not eof(fi) do begin
        read(fi,temp);
        write(temp,' ');
  end;

  (*write to output.txt*)
  for i:=3 downto 1 do begin
      for j:=3 downto 1 do begin
          write(fo,t[i,j]);
      end;
  end;
  writeln;
  reset(fo);
  (*read back fo (output.txt)*)
  write('contents of output.txt: ');
  while not eof(fo) do begin
        read(fo,temp);
        write(temp,' ');
  end;
  close(fi);
  close(fo);
  readln;
end.
(*created by FlamingClaw 2010.02.09.*)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.