题解 | 字符圣诞树
字符圣诞树
https://www.nowcoder.com/practice/0fae60c3b5c64699b7c0f031c2187dde
#include <stdio.h>
int main() {
char ch;
scanf("%c",&ch);
int row;
int j ,spacemax = 5;
int charnum=1;
for(row = 0; row< 5; row++){
for(j = 1 ; j < spacemax ;j++ ) printf(" ");//打印空格
for(int i=0; i <charnum;i++ ) printf("%c ",ch); //打印字符(注意字符加空格可以看成一个整体来输出)
spacemax--;
charnum++;
printf("\n");
}
return 0;
}