1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| #include <iostream> using namespace std; int n; int main() { scanf("%d", &n); for (int r = 0; r < 2 * n + 1; ++r) { int d = abs(r - n); if (d) printf("%*s", 2 * d, ""); int c = 0; while (c < n - d) printf("%d ", c++); printf("%d", c--); while (c >= 0) printf(" %d", c--); printf("\n"); } return 0; }
|