// 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;
}
1027
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 传送门 https://pintia.cn/problem-sets/994805260223102976/pro...
- 《黑夜与光明》 我在黑夜中奔跑却看不到光明的路标 《无可救药》 我还记得你对我的好只是我那时无可救药 《甘于平凡》...