Question: in C++ Extend the given program so that after all input strings are read, you will output for each non-empty entry of V the number

in C++ Extend the given program so that after all input strings are read, you will output for each non-empty entry of V the number of letters in that entry and the number of strings in that entry. Input: 

original program question:

Write a program where you will have a vector V where each entry is a pointer to a vector of strings. This means that each entry in V points to a vector of strings. Your program will then read input strings. For each string, if the number of characters in the string is N, then add it to the string vector in entry V[N-1]. Be sure to allocate the string vector in each entry as needed. The input string will have a maximum of 10 characters so you can initialize V with 10 entries. Do not add repeated entries. Stop when string "quit" is read. String "quit" should not be processed. Then output the contents of each V entry in order from V[0] to V[9], separated by spaces within the same V entry and by a new line when switching to the next entry. Skip empty entries.

Input:

Enter the input: A

Enter the input: Box

Enter the input: Cube

Enter the input: to

Enter the input: happy

Enter the input: hello

Enter the input: computer

Enter theinput: mouse

Enter the input: happiness

Enter the input: quit

 Output: 1 1 2 1 3 1 4 1 15 3 8 1 9 1 #include #include using namespace std; int main() { vector> V(10); string str; cout<<"Enter the input: "; cin>>str; while(str!="quit") { int len = str.size(); if(len!=0) { V[len-1].push_back(str); } cout<<"Enter the input: "; cin>>str; } for(int i=0;i<10;i++) { // iterate over each string vector for(int j=0;j

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!