|
P.56.1.
Program E_3_3_1;
uses crt, dos;
var
AA, BB : string;
K, L, S, I, J : integer;
begin
AA:='abcd';
BB:='aabdcadddcvabcdxyabcabcdw';
K:=length(BB);
L:=length(AA);
I:=1;
J:=1;
S:=0;
while (S=0) and (I<=K-L+1) do begin
if BB[I+J-1]=AA[J] then J:=J+1
else begin
I:=I+1;
J:=1
end;
if J>L then S:=I;
end;
writeln(S);
end.
P.56.4.
Program E_3_3_4;
uses crt, dos;
var
AA, BB : string;
K, L, T, I, J : integer;
begin
AA:='abcd';
BB:='aabdcadddcvabcdxyabcabcdw';
K:=length(BB);
L:=length(AA);
I:=1;
J:=1;
T:=0;
while (I<=K-L+1) do begin
if BB[I+J-1]=AA[J] then J:=J+1
else begin
I:=I+1;
J:=1
end;
if J>L then begin
T:=T+1;
I:=I+1;
J:=1
end;
end;
writeln(T);
end.
|