Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ascii pine trees

 
justin marshall
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
this is a code to print a pine tree. It just prints one big tier for any number. It works ok for one tier.
But how do I make look like this one?
*
***
*
***
*****
*
***
*****
*******
|
-----+-----

For example, if you input 3 you get 3 tiers in the tree. Base of tree is always 4 dashes wider then the bottom tier of the tree.

This is what I have so far:
 
justin marshall
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry but the pine tree got messed up.
anyway...how do I make look like this one?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This seems to work OK, but there's probably simpler ways
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't homework, is it?
 
justin marshall
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, no it's not homework.
I learn by example. I learned C that way.
thanks for asking though.
justin.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic