
Solução em Pascal do Problema 16
PROGRAM INCOMPLETO
program 5.17;
const NumMaxAlg=100;
type indices=0..NumMaxAlg;
vetor=array[indices] of Integer;
var n, m, i, j, k: Integer;
x : vetor;
achou : Boolean;
begin
readLn(n);
for i:=1 to n do Read(x[i]); ReadLn;
i:=1; achou:=false;
while (i<=n-1) and not achou do
begin
j:=i+1;
while (j+m<=n) and not achou do
if x[i] <> x[j]
then begin
j:=j+1; m:=m+1
end
else begin
achou:=true;
k:=1;
while (k<=m) and achou do
if x[i+k]=x[j+k]
then k:=k+1
else begin
achou:=false;
j:=j+1;
m:=m+1
end
end;
i:=i+1
end
end.
História
da Computação | Listas de
Exercícios | Problemas Resolvidos | macmulti@ime.usp.br