Solução em Pascal do Problema 17

PROGRAMA INCOMPLETO
program texto;

const NumMaxLin=1000;
      NumMaxCol=80;
type indLinhas=1..NumMaxLin;
     indColunas=1..NumMaxCol;
     UmaLinha=array[indColunas] of Char;
     UmTexto=array[indLinhas] of UmaLinha;
var m, n, i, j, k, l, Inic : Integer;
    a : Umtexto;

function Inicio (u:UmaLinha; n:Integer):Integer;

var i:Integer;

begin
 i:=n;
 while u[i] = ' ' do i:=i-1;
  ?
  ?
  ?
end;

procedure Insere(var t:UmTexto;var m:Integer; n,k:Integer);
var i:Integer;

begin
 for i:=m downto k+1 do t[i+1]:=t[i]
 for i:=1 to n do t[k+1][i]:=' ';
 m:=m+1
end;

begin
 readLn(m);
 readLn(n);
 for i:=1 to m do begin
  for j:=1 to n do 
   read(a[i][j]);
   readLn
 end;
 
 i:=1;
 while i<m do 
  if (a[i][n] <> ' ') and (a[i+1][1]<>' ') then begin
   inic:=Inicio(a[i],n);
   Insere(a,m,n,i);
   k:=1;
   for j:=inic to n do begin
    a[i+1,k]:=a[i,j];
    a[i,j]:=' ';
    k:=k+1;
    j:=1;
    while a[i+2,j]<>' ' do
     a[i+1,k]:=a[i+2,j];
    a[i+2,j]:=' ';
    k:=k+1;
    i:=i+2
   end
  end
  else
   i:=i+1;
 
 <imprime a>
 
end.


Lista de Problemas

História da Computação | Listas de Exercícios | Problemas Resolvidos | macmulti@ime.usp.br