题解 | #圣诞树#
圣诞树
https://www.nowcoder.com/practice/9a03096ed8ab449e9b10b0466de29eb2
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> int main() { int n = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) { for (int j = 0; j < n - i; j++) { printf(" "); } for (int j = 0; j < i; j++) { printf(" * ");///////// } printf("\n"); for (int j = 0; j < n - i; j++) { printf(" "); } for (int j = 0; j < i; j++) { printf(" * * ");////// } printf("\n"); for (int j = 0; j < n - i; j++) { printf(" "); } for (int j = 0; j < i; j++) { printf("* * * "); } printf("\n"); } for (int i = 0; i < n; i++) { for (int j = 0; j < 6 * n / 2 - 1; j++) printf(" "); printf("*\n"); } return 0; }