题解 | #箭形图案#
箭形图案
https://www.nowcoder.com/practice/a6d1081e0c9a42f19e42ed6cd91556c1
#include <stdio.h> int main() { int n = 0; while (scanf("%d", &n) == 1)//多组输入 { //打印 //先打印n行 int i = 0; for (i = 0;i < n;i++) { //先打印" " int j = 0; for (j = 0;j < n - i;j++) { printf(" "); } //后打印"*" for (j = 0;j < i+1;j++) { printf("*"); } printf("\n"); } //后打印n+1行 for (i = n + 1;i > 0;i--) { int j = 0; for (j = n + 1 - i;j > 0;j--) { printf(" "); } for (j = i;j > 0;j--) { printf("*"); } printf("\n"); } } return 0; }