#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
const int MAXN = 1005;
string str[MAXN];
int main()
{
#ifdef _LOCAL
freopen("F://input.txt", "r", stdin);
#endif
int count = 0, max = 0;
while(getline(cin, str[count]))
{
if(str[count].size() > max) max = str[count].size();
++count;
}
string beg(max + 2, '*');
cout << beg << endl;
bool flag = true;
for(int i = 0; i < count; ++i)
{
string front, back;
printf("*");
int len = max - str[i].size();
front = back = string(len / 2, ' ');
if(len % 2)
{
if(flag == false)
{
front.push_back(' ');
flag = true;
}
else
{
back.push_back(' ');
flag = false;
}
}
cout << front << str[i] << back;
printf("*\n");
}
cout << beg << endl;
return 0;
}
Codeforces 5B. Center Alignment
最新推荐文章于 2022-02-07 20:45:49 发布