A808г

Задача

Дан текст. Группы символов, разделенные пробелами (одним или несколькими) и не содержащие пробелы внутри себя, будем называть их словами.В тех словах, которые оканчиваются сочитанием букв  [latex]-ing[/latex] заменить это окончание на [latex]-ed[/latex].

Тест

Для проверки я введу первый абзац и второй, так как могут возникнуть вопросы, связанные с считыванием [latex]getline()[/latex] до первого переноса строки.

Вводимый текст Выводимый текст
Alice was beginning to get very tired of sitting

by her sister on the bank, and of having nothing

to do: once or twice she had peened into the book

her sister was reading, but it had no pictures or con-

versations in it, and what is the use of a book,’ througt

Alice ‘without pictures or conversation?’

So she was considering in her own ..

Alice was begined to get very tired of sitted

by her sister on the bank, and of haved nothed

to do: once or twice she had peened into the book

her sister was readed

, but it had no pictures or con-

versations in it, and what is the use of a book,’ througt

Alice ‘without pictures or conversation?’

So she was considered in her own …

Ссылка на программу: http://ideone.com/S5ZlwZ

Решение

Вводим строку в переменную [latex]s[/latex].В цикле пишем условие, что пока будут встречаться буквосочетания  [latex]-ing[/latex] заменить их на [latex]-ed[/latex] и выводим уже обработанный текст.

Related Images:

One thought on “A808г

Добавить комментарий