By Bruno Santos Brazil
We have some texts and we want to right justify them, that is, align them to the right. Create a program that reads a text, formats it right justifies all of its lines, printing them in the same order as they appear in the input.
The input contains several test cases. The first line of a test case will contain an integer N (1 ≤ N ≤ 100) indicating the number of lines that form the text. Each of the following N lines will contain a text, composed of 1 to 50 uppercase letters (‘A’-‘Z’) or spaces (‘ ’). All text lines will contain at least one letter. There may be more than one space character between words. Also, there may be leading and trailing spaces in the input lines. The end of input is indicated by N = 0.
For each test case print the text lines with a single space character between words, and padded on the left with space characters so that all the lines will have the same length as the longest line existing in that text. Print an empty line between all the test cases. There must be no trailing spaces printed out, and you should discard any unnecessary leading spaces, so that at least one line on every text starts with a letter.
Sample Input | Sample Output |
3 |
ROMEO AND |