Input Format:
The input is a string.
Text that is bold represents the input.
Output Format:
The output is a string.
Sample Input:
remove the occurrence of the word from entered string
Sample Output:
remove occurrence of word from entered string
SOLUTION:
#include<iostream>
using namespace std;
int main()
{
string line;
int count = 0;
getline(cin,line);
for(int i = 0; line[i] != '\0'; i++){
if(line[i] == 't')
if(line[i+1] == 'h')
if(line[i+2] == 'e'){
count = i;
line.erase(line.begin() + count, line.begin() + count +4);
}
}
for(int i = 0; line[i] != '\0'; i++){
cout<<line[i];
}
}
No comments:
Post a Comment