Center Alignment
题目(https://acs.jxnu.edu.cn/problem/CF5B)描述:
Almost every text editor has a built-in function of center text alignment. The developers of the popular in Berland text editor «Textpad» decided to introduce this functionality into the fourth release of the product.
You are to implement the alignment in the shortest possible time. Good luck!
输入:
The input file consists of one or more lines, each of the lines contains Latin letters, digits and/or spaces. The lines cannot start or end with a space. It is guaranteed that at least one of the lines has positive length. The length of each line and the total amount of the lines do not exceed 1000.
输出:
Format the given text, aligning it center. Frame the whole text with characters «*» of the minimum size. If a line cannot be aligned perfectly (for example, the line has even length, while the width of the block is uneven), you should place such lines rounding down the distance to the left or to the right edge and bringing them closer left or right alternatively (you should start with bringing left). Study the sample tests carefully to understand the output format better.
样例输入:
This is
Codeforces
Beta
Round
5
样例输出:
************
* This is *
* *
*Codeforces*
* Beta *
* Round *
* 5 *
************
样例输入:
welcome to the
Codeforces
Beta
Round 5
and
good luck
样例输出:
****************
*welcome to the*
* Codeforces *
* Beta *
* Round 5 *
* *
* and *
* good luck *
****************
翻译:
几乎每个文本编辑器都有内置的文本居中对齐功能。在波兰流行的文本编辑器«Textpad»的开发者决定在第四代产品中加入该功能。
你要在尽可能短的时间内实现对齐。祝你好运。
输入:
输入包含一或多行,每行包含英文字母、数字和空格,每行的开头和结尾都不为空格,可以保证输入至少有一行有长度(不全为空格),每行的长度和行数都不超过1000。
输出:
对给定的输入文本制表,并且居中对齐,将对齐后的文本用最小的由字符‘*’组成的矩形包围。如果一行不能被完美的对齐(例如,一行的长度为偶数,然而空格的长度却不是偶数),你应该将长度四舍五入,放到左边或右边的边缘,并交替使用使他们更加接近(你应该从左边开始),小心的观察样例输出去更好的理解。
样例输入:
This is
Codeforces
Beta
Round
5
样例输出:
************
* This is *
* *
*Codeforces*
* Beta *
* Round *
* 5 *
************
样例输入:
welcome to the
Codeforces
Beta
Round 5
and
good luck
样例输出:
****************
*welcome to the*
* Codeforces *
* Beta *
* Round 5 *
* *
* and *
* good luck *
****************