#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,flag=0;
char c;
cin >>n>>c;
int r = (int)sqrt((n + 1) / 2);
int m = 2*r-1;
for (int i = m; m >= 1; m -= 2)
{
for (int j = 0; j < flag; j++) {
cout << " ";
}
for (int j = 0; j < m; j++) {
cout<<c;
}
flag++;
cout << endl;
}
for (int i = 0; i < m+2; m+=2) {
if (m+4 > 2 * r - 1) break;
for (int j = 0; j < flag-2; j++) {
cout << " ";
}
for (int j = 0; j < m+4; j++) {
cout << c;
}
flag--;
cout << endl;
}
cout << n - (r*2*r -1);
return 0;
}
PTA 1027 打印沙漏 (20 分)
最新推荐文章于 2020-02-01 16:06:30 发布