347. Centre the Text
EasyFormatting
Centre each line in a field of width w using * as padding. If the padding is odd, put the extra * on the right. Lines longer than w are printed unchanged.
Input format
Line 1: n w Next n lines: text
Output format
The centred lines.
Example 1
Input
2 9 hello hi
Output
**hello** ***hi****
Example 2
Input
1 3 abcdef
Output
abcdef
Constraints
1 ≤ w ≤ 100
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…