In a certain area, there was a camp of polio drops team. They need to search for every baby in a particular area. They want to find the baby and take out the baby for polio drops. Help them to find the baby to avoid polio attacks. (remove the occurrence of the word "the" from the entered string).
Answers
Answered by
0
Explanation:
utd checklist for this question is gjkk
Answered by
1
Answer:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string inp;
getline(cin, inp);
size_t idx = inp.find("the");
while(idx != string::npos)
{
inp.erase(idx, 4);
idx = inp.find("the");
}
cout<<inp;
}
Explanation:
-> Getline takes input considering blank spaces.
-> while loop looks for "the" in the given sentence and returns index value of 't' in the sentence, then erase removes 4 characters (including a white space) from the index 'idx', then the loop goes on finding '"the" in the sentence until it finds none.
and loop
Similar questions