y doesnt this have an output??
Author |
Message |
person
|
Posted: Sat Mar 12, 2005 7:40 pm Post subject: y doesnt this have an output?? |
|
|
code: |
for x : 0 .. 20
for decreasing y : 1 .. 20
locate (x, y)
put x
end for
end for
|
y doesnt this output anything?[/quote] |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Cervantes

|
Posted: Sat Mar 12, 2005 7:48 pm Post subject: (No subject) |
|
|
It skips the second for loop because 1 is less than 20 and because it's decreasing.
In a regular for loop, the first number must be less than the second. In a decreasing for loop, the first number must be greater than the second.
You have a decreasing for loop in which the first number is less than the second. Switch them. |
|
|
|
|
 |
mike200015
|
Posted: Sat Mar 12, 2005 7:53 pm Post subject: (No subject) |
|
|
you also need to make the 1st for loop start at 1.. since u used locate (x,y) and the x is the for loop that starts at 0, and there is no row 0, so it needs to start at 1 |
|
|
|
|
 |
ssr

|
Posted: Sat Mar 12, 2005 8:37 pm Post subject: (No subject) |
|
|
if u want, use locatexy
and yes, whenever turing sees a decreasing thats the other way, it will automatically stop/ 8) |
|
|
|
|
 |
Token

|
Posted: Sat Mar 12, 2005 8:44 pm Post subject: (No subject) |
|
|
so the code would be
code: |
for x : 1 .. 20
for decreasing y : 20 .. 1
locate (x, y)
put x
end for
end for
|
but if u wanted the numbers to start at 0, you would have to do this
code: |
for x : 1 .. 21
for decreasing y : 20 .. 1
locate (x, y)
put x - 1
end for
end for
|
|
|
|
|
|
 |
|
|