how to show the array in matrix form and not the numbers arranged side by side? [closed]

-3

I did but it did not work:

program teste;  
 uses crt;  
 var  
   iMat: array [1..3,1..3] of integer;  
   iLin, iCol: integer;  
 begin  
   write ('Digite os números da matriz: ');  
   for iLin:=1 to 3 do  
   begin  
    for iCol:=1 to 3 do  
      read (iMat[iLin,iCol]);  
   end;  
 clrscr;  
   for iLin:=1 to 3 do  
   begin  
    for iCol:=1 to 3 do  
    gotoxy (iCol,iLin); write (iMat[iLin,iCol]);  
   end;  
 readkey;  
 end.  

How to solve?

    
asked by anonymous 08.08.2016 / 20:38

3 answers

2

I found the following error:

for iLin:=1 to 3 do
begin
for iCol:=1 to 3 do
gotoxy (iCol,iLin); write (iMat[iLin,iCol]);
end

Begin was missing before GotoXY.

Correcting:

program teste;  
 uses crt;  
 var  
   iMat: array [1..3,1..3] of integer;  
   iLin, iCol: integer;  
 begin  
  ClrScr;  
  write ('Digite os números da matriz: ');  
  for iLin:=1 to 3 do  
  begin  
   for iCol:=1 to 3 do  
   begin  
    Write ('(',iLin,',',iCol,')= ');  
    ReadLn (iMat[iLin,iCol]);  
   end;  
  end;  
  ClrScr;  
  for iLin:=1 to 3 do  
  begin  
   for iCol:=1 to 3 do  
   begin  
    gotoxy (iCol,iLin); write (iMat[iLin,iCol]);  
   end;  
  end;  
  readkey;  
 end.  
    
08.08.2016 / 20:43
4

Change the command write() by writeln() at the time of writing the result.

Change:

write (iMat[iLin,iCol]);

To:

writeln (iMat[iLin,iCol]);
    
08.08.2016 / 20:42
2

So: One for row and one for column (inside).

Program HelloWorld(output);
var
  matriz: array [1..3,1..3] of integer;
  linha, coluna: integer; 
begin
  matriz[1,1] := 1;
  matriz[1,2] := 2;
  matriz[1,3] := 3;
  matriz[2,1] := 1;
  matriz[2,2] := 2;
  matriz[2,3] := 3;
  matriz[3,1] := 1;
  matriz[3,2] := 2;
  matriz[3,3] := 3;

  for linha := 1 to 3 do
      begin

        for coluna :=1 to 3 do
            begin

                write(matriz[coluna, linha]);
                write('    ');

            end;

        writeln('');

      end;


end.
    
08.08.2016 / 21:35