Computer Science Canada Extremely basic program |
Author: | HB [ Tue Mar 06, 2012 11:17 am ] | ||
Post subject: | Extremely basic program | ||
What is the problem you are having? I can't figure out how to generate a pattern in Turing using * with for loops Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) im looking to generate a Turing program that makes this pattern
|
Author: | Zren [ Tue Mar 06, 2012 12:40 pm ] |
Post subject: | RE:Extremely basic program |
What have you tried so far? |
Author: | QuantumPhysics [ Wed Mar 07, 2012 12:26 am ] |
Post subject: | RE:Extremely basic program |
use the character ASCII value of the star and have the user enter a bottom row value. Have the program out put that number of stars and reduce one everytime, or add one every time untill it gets to the max row number |
Author: | S_Grimm [ Wed Mar 07, 2012 9:03 am ] |
Post subject: | Re: RE:Extremely basic program |
QuantumPhysics @ Wed Mar 07, 2012 12:26 am wrote: use the character ASCII value of the star and have the user enter a bottom row value. Have the program out put that number of stars and reduce one everytime, or add one every time untill it gets to the max row number
Or you know, start at the first line and each time you go to a new line add another star to the output. Take a look at For Loops inside For Loops. |
Author: | HB [ Wed Mar 07, 2012 10:40 am ] |
Post subject: | RE:Extremely basic program |
Is there a tutorial for For Loops inside For Loops? |
Author: | HB [ Wed Mar 07, 2012 10:47 am ] |
Post subject: | RE:Extremely basic program |
for y : 1 .. 8 for z : 1 .. y put "*" .. end for put"" end for muahahahahaha |
Author: | S_Grimm [ Wed Mar 07, 2012 12:50 pm ] |
Post subject: | Re: RE:Extremely basic program |
HB @ Wed Mar 07, 2012 10:47 am wrote: for y : 1 .. 8
for z : 1 .. y put "*" .. end for put"" end for muahahahahaha Looks about right. I don't have access to a Turing Compiler at work, so I cant verify. |
Author: | smool [ Wed Mar 07, 2012 4:20 pm ] | ||
Post subject: | Re: Extremely basic program | ||
|
Author: | Dreadnought [ Wed Mar 07, 2012 4:42 pm ] |
Post subject: | Re: Extremely basic program |
You can also use repeat. It's faster than nesting a for loop because you call put only once per line of '*'. On the other hand, you can't use it for lines with more than 255 '*'. (I assume that wouldn't be an issue though...) |