题解 | #翻转金字塔图案#
翻转金字塔图案
https://www.nowcoder.com/practice/c4775776e4464537bfb6a5ba37c596c6
#include <stdio.h> int main() { int n; while (scanf("%d", &n) != EOF) { for (int i = 1; i <= n; i++) //i表示行数,逐行打印 { for (int j = 1; j <= i-1; j++) //打印第i行的i-1个空格 { printf(" "); } for (int k = 1; k <= n+1-i; k++) //打印第i行的n+1-i个* { printf("* "); } printf("\n"); //打印完一行,输出换行符 } } }
在上一题的基础上修改两个地方即可。