2
c语言打印一颗简单圣诞树
source link: https://blog.51cto.com/u_15838996/5916112
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
c语言打印一颗简单圣诞树
精选 原创#include<stdio.h>
int main()
{
int i,j,t;//i用来表示有五行
for(i=1;i<=5;i++)
{
for(j=5-i;j>0;j--)
{
printf(" ");//这里打印的就是每个*前面的空格
}
for(t=1;t<=i;t++)
{
printf("* ");//这里打印的就是每行的*号*号后面的两个空格不能忘
}
printf("\n");//这里的作用就是在打印完一行*后换行打印下一行
}
return 0;
}
int main()
{
int i,j,t;//i用来表示有五行
for(i=1;i<=5;i++)
{
for(j=5-i;j>0;j--)
{
printf(" ");//这里打印的就是每个*前面的空格
}
for(t=1;t<=i;t++)
{
printf("* ");//这里打印的就是每行的*号*号后面的两个空格不能忘
}
printf("\n");//这里的作用就是在打印完一行*后换行打印下一行
}
return 0;
}
运行结果如图
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK