1027
2017-07-30 本文已影响0人
峡迩
// PATn.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
unsigned n;
string c;
cin >> n >> c;
int ret = (n+1)/2;
int max = 1;
int sum = 0;
while (ret>=1)
{
sum = sum + max;
ret = ret - max;
max = max + 2;
if (max > ret)
break;
}
max = max - 2;
cout.flags(ios::right);
for (int j = max; j > 0; j = j - 2)
{
cout.fill(' ');
if(max==j)
cout << setw((max - j) / 2) << "";
else
cout << setw((max - j)/2)<<" ";
cout.fill(c[0]);
cout << setw(j)<<c;
cout << endl;
}
if (n>=7)
{
for (int j = 3; j <= max; j = j + 2)
{
cout.fill(' ');
if (max == j)
cout << setw((max - j) / 2) << "";
else
cout << setw((max - j) / 2) << " ";
cout.fill(c[0]);
cout << setw(j)<<c;
cout << endl;
}
}
if (n < 7)
cout << n-1;
else
cout << n % (sum*2 - 1);
return 0;
}