program CountWordsWithChar; var str: string; ch: char; count, i: integer;
begin count := 0;
write('Введите строку: '); readln(str);
write('Введите символ: '); readln(ch);
str := str + ' '; // добавляем пробел в конце строки для корректной работы алгоритма
for i := 1 to length(str) do begin if (str[i] <> ' ') and (str[i] = ch) then count := count + 1 else if (str[i] = ' ') and (str[i-1] = ch) then count := count + 1; end;
writeln('Количество слов, содержащих символ "', ch, '": ', count); end.
program CountWordsWithChar;
var
str: string;
ch: char;
count, i: integer;
begin
count := 0;
write('Введите строку: ');
readln(str);
write('Введите символ: ');
readln(ch);
str := str + ' '; // добавляем пробел в конце строки для корректной работы алгоритма
for i := 1 to length(str) do
begin
if (str[i] <> ' ') and (str[i] = ch) then
count := count + 1
else if (str[i] = ' ') and (str[i-1] = ch) then
count := count + 1;
end;
writeln('Количество слов, содержащих символ "', ch, '": ', count);
end.