The input in this problem will consist of a number of lines of English text consisting of the letters of the English alphabet, the punctuation marks (') apostrophe, (.) full stop, (,) comma, (;) semicolon, (:) colon and white space characters (blank, newline). Your task is to print the words of the text in reverse order without any punctuation marks other than blanks.
For example consider the following input text:
This is a sample piece of text to illustrate this problem. If you are smart you will solve this right.
The corresponding output would read as:
right this solve will you smart are you If problem this illustrate to text of piece sample a is This That is, the lines are printed in reverse order.
Note: Individual words are not reversed.
The first line of input contains a single integer N (<=20), indicating the number of lines in the input. This is followed by N lines of input text. Each line should accept a maximum of 80 characters.
Output the text containing the input lines in reverse order without punctuation except blanks as illustrated above.
Have something to say? Log in to comment on this post.