Pascal:
Дана строка. Слова разделены пробелами. Определить количество слов заданной длины
Program Stroka
uses Сrt;
var s,temp:string;
i,c,k,d:integer;
begin
clrscr;
write(Введите строку:);
readln(s);
write(Введите длину:);
readln(k);
temp:=; c:=0;
d:=length(s);
for i:=1 to d do
begin
if s[i]<> then temp:=temp+s[i];
if ((s[i]= ) or (i=d)) and (temp<>) then
begin
if Length(temp)=k then c:=c+1;
temp:=;
end;
end;
writeln(Количество слов заданной длины: ,c);
readkey;
end.
Оцени ответ
