C语言中规中矩的大树
本文最后更新于 129 天前,其中的信息可能已经有所发展或是发生改变。

没事干,写个树玩玩,真正的 “撸树”

在 Ubuntu 终端、VScode 终端显示

代码

#include "stdio.h"
int main(){
int high = 5; //层高
int count = 5; //层数
int start; //每层开始*数
int width = 1 + 4*high; //末尾层最大宽度
int flag_count = 0; //*计数
int root_count = 0,root_temp; //树桩的大小
/* 计算末尾宽度 */
for(int i=0; i<count; i++){
start = high / 2 ;
width += start + (high);
if(i == 0)
root_count = width - (count+2)*2;
}
width = (width+2) / 2;
printf("%d\n",width);
/* 输出树 */
start = 1; //第一层的第一个为1
for(int a=0; a<count; a++){
flag_count = start;
for(int b=0; b<high; b++){
/* 打印空格 */
for(int c=0; c<width-flag_count-b; c++)
printf(" ");
/* 打印* */
for(int c=0; c<(flag_count+b)*2; c++)
printf("*");
flag_count += 2;
printf("\n");
}
start += high / 2 + 1;
}
/* 打印树桩 */
root_temp = (root_count+1)/2;
for(int a=0; a<count+1; a++){
for(int b=0; b<width-root_temp; b++)
printf(" ");
for(int c=0; c<root_count; c++)
printf("*");
printf("\n");
}
}
如果您觉得这篇文章不错,且手里较为宽裕,可以支持一下博主,一分也是缘分😊
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇