Cod sursa(job #337456)

Utilizator butler1234Cioc Stefan butler1234 Data 3 august 2009 18:12:27
Problema Potrivirea sirurilor Scor 14
Compilator fpc Status done
Runda Arhiva educationala Marime 0.67 kb
program potri_siruri;
var a,b:string;
    i,s,o,j,n,n2,l,p:integer;
    x:array[1..100]of integer  ;
    f1,f2:text;
begin
assign(f1,'strmatch.in'); reset(f1);
assign(f2,'strmatch.out'); rewrite(f2);
readln(f1,a);
read(f1,b);
n:=length(a);
n2:=length(b);
p:=1;
s:=0;
l:=1;
for i:=1 to n2-n do
   begin
   o:=1;
   if a[1]=b[i] then
      begin
      for j:=2 to n do
        if a[j]<>b[i+j-1] then
          o:=0;
          if o=1 then
          begin
          s:=s+1;
          x[l]:=i-1;
          l:=l+1;
          end;
          {write(f2,s);}
      end;
   end;

writeln(f2,s);
for p:=1 to l-1 do
  write(f2,x[p],'  ');
close(f1);
close(f2);
end.