Pagini recente » Cod sursa (job #3231561) | Cod sursa (job #3141059) | Cod sursa (job #260551) | Cod sursa (job #260606) | Cod sursa (job #265190)
Cod sursa(job #265190)
var f,g:text;
a,b:array [1..2000001] of char;
c:array[1..1001] of longint;
i,j,m,n,k,p:longint;
procedure citire;
begin
assign(f,'strmatch.in');
reset(f);
n:=0;
m:=0;
while not eoln(f) do begin
m:=m+1;
read(f,b[m]);
end;
readln(f);
while not eoln(f) do begin
n:=n+1;
read(f,a[n]);
end;
close(f);
end;
procedure strmeci;
begin
i:=1;
k:=1;
repeat
if a[i]=b[k] then k:=k+1 else begin k:=1; if a[i]=b[k] then k:=k+1; end;
if k=m+1 then begin
p:=p+1;
if p<=1000 then c[p]:=i-m;
k:=1;
i:=i-m+1;
end;
i:=i+1;
until i=n+1;
end;
procedure afisare;
begin
assign(g,'strmatch.out');
rewrite(g);
writeln(g,p);
for i:=1 to p mod 1000 do write(g,c[i],' ');
close(g);
end;
begin
citire;
strmeci; write(n,' ',m);
afisare;
end.