/*************************************************************************
> File Name: tree.c
> Author: QiyangXia
> Mail: 834061456@qq.com
> Created Time: 2021年12月17日 星期五 20时51分16秒
************************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, const char *argv[])
{
printf("\t\t送给大家的圣诞树,但现在还需要一颗种子\n");
printf("\t\t请输入一个数代表种子,推荐5-30之间:\n");
srand((unsigned)time(NULL));
char str[] = "&^$@*!._-%#&*";
int i,e,v,a,n;
scanf("%d",&i);
//第一层
for(e=0;e<=i;e+=2)
{
for(v=0;v<(i*2-e);v++)
{
printf(" ");
}
for(v=0;v<=2*e;v++)
{
int b=rand()%12;
printf("%c",str[b]);
}
printf("\n");
}
//第二层
for(a=e;a<i*3;a+=4)
{
//printf("%d,%d",a,i);
for(v=0;v<(i*2-(9*a/16));v++)
{
printf(" ");
}
for(v=0;v<=a*9/8;v++)
{
int b=rand()%12;
printf("%c",str[b]);
}
printf("\n");
}
//第三层
for(n=e;n<i*3;n+=3)
{
for(v=0;v<(i*2-(3*n/4));v++)
{
printf(" ");
}
for(v=0;v<=n*3/2;v++)
{
int b=rand()%12;
printf("%c",str[b]);
}
printf("\n");
}
//树干
for(e=0;e<i;e+=4){
for(v=0;v<(2*i-i/2);v++)
{
printf(" ");
}
for(v=0;v<=i;v++)
{
int b=rand()%12;
printf("%c",str[b]);
}
printf("\n");
}
//printf("%d,%d",e,i);
return 0;
}