https://pintia.cn/problem-sets/17/problems/260
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
char sign;
cin >> N >>
sign;
int count =
1;
while (
2 * count * count -
1 <=
N)
{
count++
;
}
count--
;
for (
int i =
0; i <
2 * count -
1; i++
)
{
for (
int j =
0; j < count -
1 - abs(count -
1 - i); j++
)
{
printf(" ");
}
for (
int j =
0; j <
2 * abs(count -
1 - i) +
1; j++
)
{
printf("%c", sign);
}
printf("\n");
}
printf("%d", N - (
2 * count * count -
1));
return 0;
}
转载于:https://www.cnblogs.com/ruoh3kou/p/10390434.html
相关资源:PTA打印沙漏L1-002打印沙漏