[問題] c語言聖誕樹並排
實在想不通...不知道有沒有大大可以提供一下意見...。
#include<stdio.h>
#include<stdlib.h>
void tree(int x);
int main()
{
int Height, Length, Width, Leaf, Stem, Index, Heightt, Heighttt;
printf("請輸入你想要聖誕葉的高度(0~39且為奇數):");
scanf("%d,%d,%d",&Height,&Heightt,&Heighttt);
tree(Height);
tree(Heightt);
tree(Heighttt);
Width = Height*2-1;
Length = Height/2;
system("pause");
return 0;
}
void tree(int x)
{int Height, Length, Width, Leaf, Stem, Index, Heightt, Heighttt;
Width = x*2-1;
Length = x/2;
if ((x > 0)&&(x < 40)&&(x%2 != 0))
{
for (Leaf = 0; Leaf < x; Leaf++)
{
for (Index = 1; Index <= Width; Index++)
{
if ((Index <= x+Leaf)&&(Index >= x-Leaf))
printf("*");
else
printf("-");
}
printf("\n");
}
for (Stem = 0; Stem < Length; Stem++)
{
for (Index = 1; Index <= Width; Index++)
{
if (Index == x)
printf("*");
else
printf("-");
}
printf("\n");
}
}
return;
}
可顯示出三顆串聯的聖誕樹...
如圖:
--*--
-***-
*****
--*--
----*----
---***---
--*****--
-*******-
*********
----*----
----*----
------*------
-----***-----
----*****----
---*******---
--*********--
-***********-
*************
------*------
------*------
------*------
可是我想改成"並排"的三棵聖誕樹,如圖
--*-- ----*---- ------*------
-***- ---***--- -----***-----
***** --*****-- ----*****----
--*-- -*******- ---*******---
********* --*********--
----*---- -***********-
----*---- *************
------*------
------*------
------*------
試了一天...還是改不出來QQ
怎麼會這樣ˊˋ
有大大會的嗎QQ?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.60.64.23
→
04/28 23:33, , 1F
04/28 23:33, 1F
推
04/29 01:07, , 2F
04/29 01:07, 2F
推
04/29 01:09, , 3F
04/29 01:09, 3F
推
04/29 07:23, , 4F
04/29 07:23, 4F
推
04/29 07:23, , 5F
04/29 07:23, 5F
推
04/29 07:23, , 6F
04/29 07:23, 6F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 3 篇):
問題
5
6