uses crt;
const s1:string[200] ='aaa bbb ccc ddd';
      s2:string[200] ='ccc';
var i,j,k:integer;
    s:string[200];
begin
clrscr;
for j:=1 to length(s1) do
 begin
  if s1[j]<>' ' then
    s:=s+s1[j]
   else
    begin
     inc(i);
     k:=pos(s,s2);
     if k<>0 then
      if ((s[k-1]=' ') or (k-1=0))
      and ((s[k+length(s)]=' ') or (k+length(s)>length(s2)))
      then writeln(s);
    s:='';
    end;
 end;

readkey;
end.