2

c语言打印一颗简单圣诞树

 1 year ago
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语言打印一颗简单圣诞树

精选 原创

爱莉希雅我的最爱 2022-12-06 15:00:48 ©著作权

文章标签 i++ #include 文章分类 C/C++ 编程语言 阅读数231

#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;
}

运行结果如图

c语言打印一颗简单圣诞树_i++

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK