- 194
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
Your program must align a text, line by line, to the width of the largest line of the text and according to the requested alignment:Input
Line 1: The requested alignment, either LEFT , RIGHT , CENTER , or JUSTIFY
Line 2: N, the number of text lines
Next N lines: A line of text to align
Line 2: N, the number of text lines
Next N lines: A line of text to align
Output
N lines of the original text, aligned according to specifications
Do NOT print trailing whitespace forLEFT or CENTER alignments
Do NOT print trailing whitespace for
Constraints
1≤N≤10
The input text never contains any leading or trailing whitespace, and when a line contains multiple words, they are always separated by a single space.
The input text never contains any leading or trailing whitespace, and when a line contains multiple words, they are always separated by a single space.
Example
Input
LEFT 4 Never gonna give you up, never gonna let you down Never gonna run around and desert you Never gonna make you cry, never gonna say goodbye Never gonna tell a lie and hurt you
Output
Never gonna give you up, never gonna let you down Never gonna run around and desert you Never gonna make you cry, never gonna say goodbye Never gonna tell a lie and hurt you
A higher resolution is required to access the IDE