CF5B.Center Alignment

普及-

通过率:0%

时间限制:1.00s

内存限制:64MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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!

几乎每个文本编辑器都内置了文本居中对齐功能。Berland 地区广受欢迎的文本编辑器 «Textpad» 的开发者决定在该产品的第四版中引入此功能。

你需要在尽可能短的时间内实现该对齐功能。祝你好运!

输入格式

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.

输入文件由一行或多行组成,每行包含拉丁字母、数字和/或空格。每行不能以空格开头或结尾。保证至少有一行的长度为正。每行的长度以及总行数均不超过 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.

将给定文本居中对齐。用最少数量的字符 * 将整个文本框起来。如果某行无法完美居中(例如,该行长度为偶数,而框的总宽度为奇数),则应将该行向左或向右偏移,偏移量取到左/右边缘距离的向下取整值;且需交替地优先向左、再向右偏移(首次偏移应优先向左)。请仔细研究样例测试,以更好地理解输出格式。

输入输出样例

  • 输入#1

    This  is
    
    Codeforces
    Beta
    Round
    5

    输出#1

    ************
    * This  is *
    *          *
    *Codeforces*
    *   Beta   *
    *  Round   *
    *     5    *
    ************
  • 输入#2

    welcome to the
    Codeforces
    Beta
    Round 5
    
    and
    good luck

    输出#2

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

输入解题思路,AI测评打分。不知道怎么写?

首页