Computer Science Canada christmas tree problem |
Author: | junkpro11 [ Tue May 04, 2004 4:17 pm ] |
Post subject: | christmas tree problem |
lol does anyone know how to make a christmas tree like this? ----* ---*** --***** -******* ignore the dashes.... thanks |
Author: | Cervantes [ Tue May 04, 2004 4:21 pm ] | ||
Post subject: | |||
ya, read up on the "put" command. here's what the code will look like:
|
Author: | junkpro11 [ Tue May 04, 2004 4:25 pm ] |
Post subject: | |
sorri i wasnt clear i dont want to just use "put" i want to get a number, eg like 5 and make a christmas tree like this: --* -*** ***** again ignore the dashes |
Author: | Cervantes [ Tue May 04, 2004 4:39 pm ] | ||
Post subject: | |||
oh, okay thats a pretty good question actually. simplest way is to use repeat and a for loop and play around with it until you get it ![]() heres what i came up with
|
Author: | junkpro11 [ Tue May 04, 2004 4:48 pm ] |
Post subject: | |
thanks for ur help!!!!!! i need to make a circle now with the asterisks...i think the closest thing i can make is an octagon though......so can i use repeat for making a "circle"? |
Author: | Cervantes [ Tue May 04, 2004 5:24 pm ] | ||
Post subject: | |||
interesting problem. heres what i came up with:
unfortunately in text the width of a character is less than its height, so it looks very, very off. also it looks off because locate requires rounding. |
Author: | Paul [ Tue May 04, 2004 5:51 pm ] |
Post subject: | |
Hey, if u enter 5, it looks like a rupee in Zelda! |
Author: | junkpro11 [ Tue May 04, 2004 7:32 pm ] |
Post subject: | |
um....sorri if this sounds dumb.....but can u explain the code u did cuz i am new at this and i duno wat that code meant.... ![]() |
Author: | Cervantes [ Tue May 04, 2004 7:40 pm ] |
Post subject: | |
i don't really know what it means either ![]() but basically, i used the equation of a circle. thats x^2 + y^2 = r^2. rearange that so that we get y^2 = r^2 - x^2, then sqrt it all so we get y = sqrt (r^2 - x^2). so now we've got x and y values (got x because we are just increasing x every time). so now locate at (x,y) and draw a *. I've got 2 locates and 2 puts. look what happens when you take one of them out. and as for the for loop being 1 .. radius * 2 + 1, look what happens when you take off the + 1. look what happens when you take off the *2. this is how i program ![]() ![]() |
Author: | junkpro11 [ Tue May 04, 2004 8:11 pm ] |
Post subject: | |
wow.....well im a slow processor so i'll think about it for a while....thanks alot for the help! |