跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1478. Center Alignment

    ID: 1484 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 2 上传者: 标签>模拟字符串编程与模拟基础难度共享题库Codeforces英文题面题目来源题面语言

Center Alignment

题目描述

B. Center Alignment
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard output

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!

Input

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.

Output

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.

Examples
Input
This  is

Codeforces
Beta
Round
5
Output
************
* This is *
* *
*Codeforces*
* Beta *
* Round *
* 5 *
************
Input
welcome to the
Codeforces
Beta
Round 5

and
good luck
Output
****************
*welcome to the*
* Codeforces *
* Beta *
* Round 5 *
* *
* and *
* good luck *
****************

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 986 题。保留原作者与原赛事署名。