asked 41.7k views
1 vote
Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. The output of the program is every word in the list that contains the character at least once. Assume at least one word in the list will contain the given character.Ex: If the input is:4 hello zoo sleep drizzle zthen the output is:zoodrizzle

asked
User Ppareja
by
8.5k points

1 Answer

3 votes

Answer:

try this.

Step-by-step explanation:

#include <iostream>

#include <vector>

using namespace std;

int main() {

int n;

cin>>n;

vector<string> v;

string s;

for(int i = 0;i<n;i++){

cin>>s;

v.push_back(s);

}

char ch;

cin>>ch;

for(int i = 0;i<v.size();i++){

for(int j = 0;j<v[i].length();j++){

if(v[i][j]==ch){

cout<<v[i]<<endl;

break;

}

}

}

return 0;

}

answered
User Luke Mills
by
9.0k points

No related questions found