Skip to content

Printing 2n lines in reverse sequence

venuprasad naik edited this page Aug 14, 2017 · 1 revision

Q7. Printing 2n lines in reverse sequence

Write a program that reads 2n non-blank lines of input (terminated by a blank line), where n is a positive integer. The program should print the last n lines followed by the first n lines last. You can assume that each line is at most 100 characters long. The maximum value of n is not known.

Example input: Line 1 Line 2 ... Line 2n

Output: given lines of text reordered as follows. Line n+1 Line n+2 ... Line 2n Line 1 Line 2 ... Line n

Clone this wiki locally