题解 | 反斜线形图案
反斜线形图案
https://www.nowcoder.com/practice/7b066963c4eb4d188becd18c37dfe22d
#include <stdio.h> int main() { int n = 0; while (scanf("%d", &n) != EOF) { if (n >= 2 && n <= 20) { for (int i = 0; i < n; i += 1) { for (int j = 0; j < i; j++) { printf(" "); } for (int k = 0; k <= i; k++) { if (k == i) { printf("*"); } } printf("\n"); } } else { printf("输入不在范围\n"); break; } } return 0; }