#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ int t; scanf("%d", &t); getchar(); char c; int n; while (t--) { scanf("%c %d", &c, &n); getchar(); if (n == 0) { continue; } else if (n == 1) { printf("%c\n", c); } else { for (int j = 0;j < n - 1;j++) { printf(" "); } printf("%c\n", c); for (int i = 1;i < n - 1;i++) { for (int j = 0;j < n - i - 1;j++) { printf(" "); } printf("%c", c); for (int j = 0;j < 2 * i - 1;j++) { printf(" "); } printf("%c", c); printf("\n"); } for (int j = 0;j < 2 * n - 1;j++) { printf("%c", c); } printf("\n"); } } } |
Double click to view unformatted code.