1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Hatshy [7]
3 years ago
6

Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. T

he 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 z
then the output is:
zoo
drizzle
To achieve the above, first read the list into a vector. Keep in mind that the character 'a' is not equal to the character 'A'.
5.23.1: LAB: Contains the character
#include
#include
using namespace std;
int main() {
/* Type your code here. */
return 0;
}
Computers and Technology
1 answer:
hammer [34]3 years ago
4 0

Answer:

In C++:

#include<iostream>

#include<vector>

using namespace std;

int main() {

int len;

cout<<"Length: ";  cin>>len;

string inpt;

vector<string> vect;

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

   cin>>inpt;

   vect.push_back(inpt); }

char ch;

cout<<"Input char: ";  cin>>ch;  

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

   size_t found = vect.at(i).find(ch);  

       if (found != string::npos){

           cout<<vect.at(i)<<" ";

           i++;

       }

}  

return 0;

}

Explanation:

This declares the length of vector as integer

int len;

This prompts the user for length

cout<<"Length: ";  cin>>len;

This declares input as string

string inpt;

This declares string vector

vector<string> vect;

The following iteration gets input into the vector

<em>for(int i =0;i<len;i++){ </em>

<em>    cin>>inpt; </em>

<em>    vect.push_back(inpt); } </em>

This declares ch as character

char ch;

This prompts the user for character

cout<<"Input char: ";  cin>>ch;  

The following iterates through the vector

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

This checks if vector element contains the character

   size_t found = vect.at(i).find(ch);  

If found:

       if (found != string::npos){

Print out the vector element

           cout<<vect.at(i)<<" ";

And move to the next vector element

           i++;

       }

}  

You might be interested in
Anyone help me with number 41.
Katarina [22]
It is te = t I yhink
8 0
3 years ago
A spreadsheet has some values entered: Cell A1 contains 10, cell A2 contains 14, cell A3 contains 7. You enter in cell A4 the fo
Alinara [238K]
A1 is 10, so your answer is 10+2=12
B. 12
6 0
3 years ago
Read 2 more answers
Working ____ means that you are viewing previously loaded or saved webpages in the browser, but you are not connected to the int
uysha [10]
Working offline is the answer
8 0
3 years ago
What are the four levels of access rights?
Svet_ta [14]

Explanation:

Currently, there are four primary types of access control models: mandatory access control (MAC), role-based access control (RBAC), discretionary access control (DAC), and rule-based access control (RBAC). Each model

5 0
3 years ago
Whats the keyboard command that will allow you to "copy" text?
Thepotemich [5.8K]

For windows machines, holding down the "control" or "Ctrl" button while pressing C will copy text, while pressing x will cut the text

For macs, Instead of pressing control, press "Command" or "Cmd" keys while pressing "c" or "x".

hope i helped and brainliest would be awesome

5 0
3 years ago
Read 2 more answers
Other questions:
  • Given an array a, declared to contain 34 elements, write an expression that refers to the last element of the array.
    12·1 answer
  • Which of these is an example of an integrated presentation?
    10·1 answer
  • What are advantages and disadvantages of developing a more robust Internet of Things and continuing to add more smart nodes?
    10·1 answer
  • What doyou mean by process model and project model?
    6·1 answer
  • cout &lt;&lt; "Part 1" &lt;&lt; endl; // Part 1 // Enter the statement to print the numbers in index 4 and index 9 // put a spac
    11·1 answer
  • What is "mob of the dead"?
    7·1 answer
  • Research and build a chroot jail that isolates ssh users who belong to the restrictssh group. (You will also need to create the
    9·1 answer
  • What is the result when you run the following line of code after a prompt??
    5·1 answer
  • Find the unknown quantities
    12·1 answer
  • PYTHON:Given the dictionary, d, find the largest key in the dictionary and associate the corresponding value with the variable v
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!