题解 | #菱形图案#
菱形图案
https://www.nowcoder.com/practice/8b935f8ffe99445dbd42494febd13e45
#include <stdio.h> int main() { int n; while (scanf("%d", &n) != EOF) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") for (int i = n + 1; i > 0; i--) { for (int j = i; j > 1; j--) { printf(" "); } int num = i; while ( num++ <= n + 1) { printf("* "); } printf("\n"); } for (int i = 0; i < n ; i++) { for (int j = 0; j <= i; j++) { printf(" "); } int num = n - i; while (num--) { printf("* "); } printf("\n"); } } return 0; }