#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
void color(short x); //自定义改变颜色 绿色为2
void tree1(int n);
void tree2(int n);
void tree3(int n);
void root();
int main()
{
printf(" ");
color(2);
tree1(1);
tree1(3);
tree2(5);
tree3(7);
root();
return 0;
}
//自定义改变颜色
void color(short x)
{
if(x>=0&&x<=15)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),7);
}
void tree1(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=(n-i+40);j++)
printf(" ");
for(j=1;j<i*2;j++)
{
color(j);
printf("*");
}
printf("\n");
}
}
void tree2(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=(n-i+38);j++)
printf(" ");
for(j=1;j<i*2;j++)
{
color(j+1);
printf("*");
}
printf("\n");
}
}
void tree3(int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=(n-i+36);j++)
printf(" ");
for(j=1;j<i*2;j++)
{
color(j+2);
printf("*");
}
printf("\n");
}
}
void root()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=41;j++)
printf(" ");
for(j=1;j<=3;j++)
{
color(15);
printf("*");
}
printf("\n");
}
}