G***G 发帖数: 16778 | 1 when N is a number you obtain from keyboard,
how to achieve the embedded loop:
for (int i1...)
for (int i2...)
for (int i3...)
....
for (int iN...)
}}}}}}....}}}} |
g*****g 发帖数: 34805 | |
b***i 发帖数: 3043 | 3 这是我初二还是初三就想明白的东西。你想啊,你用Apple ][ BASIC语言写了循环语句
,那么解释程序是怎么动态地根据你写的程序来决定循环层数和什么时候退出循环呢?
提示,你要做的就是来解释循环语句。建立几个数组,Start[], End[], I[],除此之
外,还要一个变量表示现在的下标,比如是p。那么你判断I[P]>End[P]的时候,基本上
要P=P-1,然后决定是否继续。
这个问题你最好自己搞清楚了,看别人答案不算啊。
【在 G***G 的大作中提到】 : when N is a number you obtain from keyboard, : how to achieve the embedded loop: : for (int i1...) : for (int i2...) : for (int i3...) : .... : for (int iN...) : }}}}}}....}}}}
|
b*****e 发帖数: 131 | 4 可以参考《电话号码转单词》那个题的解法,用两层while实现不确定层次的循环嵌套
。 |
d*****l 发帖数: 8441 | 5 理论上讲单层循环和多层循环是等效的,所不同的只是循环变量的控制逻辑而已。 |
c*********e 发帖数: 16335 | 6 递归不是啥好方法,用的层太多不好。
【在 G***G 的大作中提到】 : when N is a number you obtain from keyboard, : how to achieve the embedded loop: : for (int i1...) : for (int i2...) : for (int i3...) : .... : for (int iN...) : }}}}}}....}}}}
|
m********2 发帖数: 89 | 7 one dimension array to story N index numbers. each index to the nth looping
list.
one while loop to change the indices.
when nth index goes to the end, wrap it back to 0 and the n+1th index
increment 1. (smaller n for inner loop).
【在 G***G 的大作中提到】 : when N is a number you obtain from keyboard, : how to achieve the embedded loop: : for (int i1...) : for (int i2...) : for (int i3...) : .... : for (int iN...) : }}}}}}....}}}}
|