Allow the user to enter a list of movie titles until typing "Done". Add each movie title to a vector. After populating the vector, print all the titles. Then, remove from the vector all the titles from the list that include the word "the" (or "The") in its title and print the remaining titles.
Sample Input:
Captain Marvel The Lego Movie 2 Aladdin The Dark Knight Ant-Man and the Wasp Done
Sample Output:
Initial List: Captain Marvel The Lego Movie 2 Aladdin The Dark Knight Ant-Man and the Wasp Titles without "the": Captain Marvel Aladdin
c++
#include "string"
#include <string>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<string> v1;
cout<<"Please Enter movie names. Enter Done to exit\n";
string name;
while(true){
getline(cin,name);
if(name=="Done") break;
else
{
v1.push_back(name);
}
}
cout<<"\nInitial List:\n";
for(vector<string>::iterator
itr=v1.begin();itr!=v1.end();++itr)
cout<<*itr<<"\n";
cout<<"\nTitles without \"the\":\n";
for(vector<string>::iterator
itr=v1.begin();itr!=v1.end();++itr)
{
string s1 = *itr;
if (s1.find("the") != std::string::npos ||
s1.find("The") != std::string::npos)
{
}
else
{
cout<<*itr<<"\n";
}
}
return 0;
}
Allow the user to enter a list of movie titles until typing "Done". Add each movie...