Предмет: Информатика,
автор: milatoria
Задана строка символов. Группы символов, разделенные пробелом и не
содержащие пробелов внутри себя, будем называть словами. Найти количество слов в строке, у которых первый и последний символ совпадают.
Ответы
Автор ответа:
1
var
currentPos,wordsAmount:byte; groupWords:string;
procedure isCorrect(startPos:byte);
begin
while currentPos+1<=length(groupWords) do
if groupWords[currentPos+1]<>' ' then inc(currentPos) else break;
if groupWords[startPos]=groupWords[currentPos] then
inc(wordsAmount);
end;
begin
readln(groupWords); wordsAmount:=0; currentPos:=1;
while currentPos<=length(groupWords) do
begin
if (groupWords[currentPos]<>' ') then isCorrect(currentPos);
inc(currentPos);
end;
writeln(wordsAmount); readln;
end.
currentPos,wordsAmount:byte; groupWords:string;
procedure isCorrect(startPos:byte);
begin
while currentPos+1<=length(groupWords) do
if groupWords[currentPos+1]<>' ' then inc(currentPos) else break;
if groupWords[startPos]=groupWords[currentPos] then
inc(wordsAmount);
end;
begin
readln(groupWords); wordsAmount:=0; currentPos:=1;
while currentPos<=length(groupWords) do
begin
if (groupWords[currentPos]<>' ') then isCorrect(currentPos);
inc(currentPos);
end;
writeln(wordsAmount); readln;
end.
Похожие вопросы
Предмет: Английский язык,
автор: HappyEmma157
Предмет: Русский язык,
автор: GGG22845
Предмет: Русский язык,
автор: Sad1Girl
Предмет: Русский язык,
автор: alisagordienco7589
Предмет: Химия,
автор: timofeymorozov2gfvgc