Question: Description Your program will allow the user to type in several lines of a poem. The user will signal the end of their input by

Description Your program will allow the user to type in several lines of a poem. The user will signal the end of their input by typing a single dot (.) on a new line. After the end of the input stage, the program will tell the user (on stdout) how many lines and words are in the poem and how many words are on each line of the poem. The first line of output provides the total words and lines in the poem, and the second line is a space-delimited list of the number of words on each line of the poem provided.

See Sample Input and Output for more details.

Sample Input and Output

Enter the poem:

Now is the winter of our discontent

Made glorious summer by this

Sun of York . 1

5 words on 3 lines

7 5 3

Sample Input and Output Explanation - The user is prompted to enter the poem into stdout, with each line of the poem on its own line. The user inputs three lines in this example, and the inputs . and hits enter to end the program (This is the red text above). - The program them indicates the total number of words in the poem, and the total number of lines inputted (15 and 3, respectively). This is the first of two lines of output. - The second line is a space-delimited list of the number of words on each line. In this case, the three lines of the poem has seven words on the first line, five words on the second line, and three words on the third line. - The program ends the space-delimited list with a newline.

Constraints Input: Lines of poetry

Contain no punctuation

No word can be greater than 20 characters in length

No line can be greater than 100 characters in length

You must not use static allocation of arrays they must be allocated dynamically. The number of input lines is unknown, so you must dynamically reallocate your array as the program runs.

Output

The first line of output will have the following format x words on y lines where x is the number of words and y is the number of lines and there are single spaces (blank characters) between each number or word. If words or lines = 1 then words should be changed to word and lines to line, respectively.

The second line of output will have a format as shown in the above sample input / output scenario (basically number of words on each line separated by spaces)

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!