没有合适的资源?快使用搜索试试~ 我知道了~
c语言圣诞树代码.docx
需积分: 2 0 下载量 72 浏览量
2023-12-30
18:46:54
上传
评论
收藏 10KB DOCX 举报
温馨提示
试读
2页
c语言圣诞树代码
资源推荐
资源详情
资源评论
c 语言圣诞树代码
#include <stdio.h>
void printSpaces(int n) {
for (int i = 0; i < n; i++) {
printf(" ");
}
}
void printStars(int n) {
for (int i = 0; i < n; i++) {
printf("*");
}
}
void printTree(int height) {
for (int i = 1; i <= height; i++) {
printSpaces(height - i);
printStars(2 * i - 1);
printf("");
}
// Print tree trunk
printSpaces(height - 1);
printf("| |");
printSpaces(height - 1);
printf("| |");
}
int main() {
int treeHeight;
printf("Enter the height of the Christmas tree: ");
scanf("%d", &treeHeight);
printTree(treeHeight);
return 0;
资源评论
常驻客栈
- 粉丝: 1w+
- 资源: 1366
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功