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(" "); } printf("%d", N - (2 * count * count - 1)); return 0; }