Pagini recente » Cod sursa (job #2504091) | Cod sursa (job #75407) | Cod sursa (job #2559120) | Cod sursa (job #1371971) | Cod sursa (job #144195)
Cod sursa(job #144195)
program strmatch;
type str = array [1..2000000] of string[1];
var A,B : str;
C : array [1..2000000] of longint;
m,n,i,j,s : longint;
f : text;
ok : boolean;
begin
assign(f,'strmatch.in');
reset(f);
n := 0;
while not eoln(f) do begin
inc(n);
read(f,A[n]);
end;
readln(f);
m := 0;
while not eoln(f) do begin
inc(m);
read(f,B[m]);
end;
close(f);
s := 0;
for i := 1 to m do
if B[i]=A[1] then begin
ok := true;
for j := 1 to n-1 do
if B[i+j]<>A[1+j] then begin
ok := false;
break;
end;
if ok then begin
inc(s);
C[s] := i;
end;
end;
assign(f,'strmatch.out');
rewrite(f);
writeln(f,s);
for i := 1 to s do
write(f,C[i]-1,' ');
close(f);
end.