题解 | #字符圣诞树#
字符圣诞树
https://www.nowcoder.com/practice/0fae60c3b5c64699b7c0f031c2187dde
#include <stdio.h> int main() { char ch; scanf("%c",&ch); /*printf(" %c\n",ch) ; printf(" %c %c\n",ch,ch); printf(" %c %c %c\n",ch,ch,ch); printf(" %c %c %c %c\n",ch,ch,ch,ch); printf("%c %c %c %c %c\n",ch,ch,ch,ch,ch);*/ int i,j; for(i=0;i<5;i++) { for(j=0;j<5-i-1;j++) { printf(" "); } for(j=0;j<=i;j++) { printf("%c ",ch); } printf("\n"); } return 0; }
注意数组应用