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