Var s: string; p, nb: integer; begin write('text? '); readln(s); p := 1; while p <= length(s) do begin while (s[p] = ' ') and (p <= length(s)) do inc(p); if (p <= length(s)) and (s[p] = 'b') then inc(nb); while (s[p] <> ' ') and (p <= length(s)) do inc(p); end; write('num words: ', nb); end.
s: string;
p, nb: integer;
begin
write('text? ');
readln(s);
p := 1;
while p <= length(s) do begin
while (s[p] = ' ') and (p <= length(s)) do inc(p);
if (p <= length(s)) and (s[p] = 'b') then inc(nb);
while (s[p] <> ' ') and (p <= length(s)) do inc(p);
end;
write('num words: ', nb);
end.