1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| Program essaiii;
uses dos,crt;
Type Seq=array[1..20] of char;
var i,j,LgSequence, LgExtrait : integer;
Sequence, Extrait : Seq;
baseseq, baseext : char;
Function EstSousSeq (LgSequence, LgExtrait : Integer; Sequence, Extrait : Seq) : Boolean;
Var IndiceSequence, IndiceExtrait : Integer;
Begin
IndiceSequence := 1;
IndiceExtrait := 1;
while (IndiceExtrait <= LgExtrait) and (IndiceSequence <= LgSequence) do
begin
if Extrait[IndiceExtrait] = Sequence[IndiceSequence]
then
Inc(IndiceExtrait);
Inc(IndiceSequence);
end;
EstSousSeq := (IndiceExtrait > LgExtrait);
End;
begin
writeln('Entrez la longueur de la sequence');
readln(LgSequence);
writeln('Entrez la longueur de l extrait');
readln(LgExtrait);
for i:=1 to LgSequence do
begin
writeln('Entrez dans la sequence le terme ',i);
readln(baseseq);
Sequence[i]:=baseseq;
end;
for j:=1 to LgExtrait do
begin
writeln('Entrez dans l extrait le terme ',j);
readln(baseext);
Extrait[j]:=baseext;
end;
for i:=1 to Lgsequence do write(Sequence[i],' ');
writeln;
for j:=1 to LgExtrait do write(Extrait[j], ' ');
writeln;
EstSousSeq(LgSequence,LgExtrait,Sequence,Extrait);
writeln;
readln;
end. |
Partager