由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 如何实现N层循环嵌套
相关主题
重复利用threads的问题【包子求助】20M*20M的loop怎么搞?
how to deal with high dimension for loop?Perl 6 改动很大很恶心
10个包子请教一个简单的编程问题多重嵌套循环会不会导致栈溢出?
问个C++算法如何编程实现循环嵌套的次数?
弱问:C的for/while循环能在括号里面continue吗?BASIC语言能传递数组的一个维给函数吗?
how to assign new value to loop variables?大家看看这道C语言题是怎么回事?
LabVIEW问题:对高手来说很简单!how to use array to simulate multi loops
请教一道练习题(C,OS)如何让C程序在运行时接受键盘控制而终止?
相关话题的讨论汇总
话题: int话题: 循环话题: loop话题: index话题: nth
进入Programming版参与讨论
1 (共1页)
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
2
递归。
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...)
: }}}}}}....}}}}

1 (共1页)
进入Programming版参与讨论
相关主题
如何让C程序在运行时接受键盘控制而终止?弱问:C的for/while循环能在括号里面continue吗?
new and delete in c++how to assign new value to loop variables?
c#中,如何写1个for loop得出"aa","ab","ac",..."zz"的所有组合?LabVIEW问题:对高手来说很简单!
How can matlab loop over functions请教一道练习题(C,OS)
重复利用threads的问题【包子求助】20M*20M的loop怎么搞?
how to deal with high dimension for loop?Perl 6 改动很大很恶心
10个包子请教一个简单的编程问题多重嵌套循环会不会导致栈溢出?
问个C++算法如何编程实现循环嵌套的次数?
相关话题的讨论汇总
话题: int话题: 循环话题: loop话题: index话题: nth