uses
crt;
const
dividers = [' ', ',', '.', ';', ':', '-', '=', '+']; { дописать нужные }
var
s, temp: string;
i, j, c, ca: integer;
begin
clrscr;
writeln('Введите строку:');
readln(s);
temp := '';
c := 0;
{ пробегаем всю строку посимвольно }
for i := 1 to length(s) do
begin
if not(s[i] in dividers) then
temp := temp + s[i];
if (s[i] in dividers) or (i = length(s)) then
begin
if temp <> '' then
begin
ca := 0;
for j := 1 to length(temp) do
if temp[j] in ['а', 'А', 'a', 'A'] then
inc(ca);
temp := '';
inc(c)
end;
end;
end;
writeln('Количество букв "а" в последнем слове: ', ca, '. Всего слов: ', c)
end.