一个关于嵌套for循环的问题.. [英] A Quesiton about nesting for loops..
问题描述
我需要制作一个使用可变数量的嵌套
for循环的应用程序。
现在我正在使用固定的数字:
for(z = 0; z< Z; ++ z)
for(y = 0; y< Y; ++ y)
for(x = 0; x< X; ++ x)
事情是可能需要更少或更多的嵌套循环。
我怎么写这个for循环的数量是一个变量?
I have a need to make an applicaiton that uses a variable number of nested
for loops.
for now I''m using a fixed number:
for (z=0; z < Z; ++z)
for (y=0; y < Y; ++y)
for (x=0; x < X; ++x)
The thing is there could be less or more nested loops necessary.
How can I write this such that the number of for loops is a variable?
推荐答案
在comp.lang中。 c ++
" JustSomeGuy" <无** @ nottelling.com>写道:
In comp.lang.c++
"JustSomeGuy" <no**@nottelling.com> wrote:
我需要制作一个使用可变数量的嵌套
for循环的应用程序。
现在我来了使用固定数字:
for(z = 0; z< Z; ++ z)
for(y = 0; y< Y; ++ y)> for(x = 0; x< X; ++ x)
事情是可能需要更少或更多的嵌套循环。
如何编写这样的数字for循环是一个变量吗?
I have a need to make an applicaiton that uses a variable number of nested
for loops.
for now I''m using a fixed number:
for (z=0; z < Z; ++z)
for (y=0; y < Y; ++y)
for (x=0; x < X; ++x)
The thing is there could be less or more nested loops necessary.
How can I write this such that the number of for loops is a variable?
什么是更大?你试图解决的问题? 20多年来,
我从来不需要做你正在做的事情。
What is the "larger" problem you are trying to solve? In over 20 years,
I''ve never needed to do what you''re doing.
N维数学。
" Bruce" <峰; br *** @ nospam.com>在消息中写道
news:3f *************** @ news.houston.sbcglobal.net。 ..
N dimensional math.
"Bruce" <br***@nospam.com> wrote in message
news:3f***************@news.houston.sbcglobal.net. ..
在comp.lang.c ++
" JustSomeGuy" <无** @ nottelling.com>写道:
In comp.lang.c++
"JustSomeGuy" <no**@nottelling.com> wrote:
我需要制作一个使用可变数量的
嵌套循环的应用程序。
现在我正在使用一个固定的数字:
for(z = 0; z< Z; ++ z)
for(y = 0; y< Y; ++ y)
for(x = 0; x< X; ++ x)
事情是可能需要更少或更多的嵌套循环。
我怎么能写这样的数量for loops是一个变量?
I have a need to make an applicaiton that uses a variable number of nestedfor loops.
for now I''m using a fixed number:
for (z=0; z < Z; ++z)
for (y=0; y < Y; ++y)
for (x=0; x < X; ++x)
The thing is there could be less or more nested loops necessary.
How can I write this such that the number of for loops is a variable?
什么是更大的?你试图解决的问题? 20多年来,
我从来不需要做你正在做的事情。
What is the "larger" problem you are trying to solve? In over 20 years,
I''ve never needed to do what you''re doing.
[不要(重复为了您的方便,请不要)顶部,重新排列]
2003年9月17日星期三21:19:17 -0600,JustSomeGuy <无** @ nottelling.com>写道:
[Do not (repeated for your convenience, DO NOT) top-post, rearranged]
On Wed, 17 Sep 2003 21:19:17 -0600, "JustSomeGuy" <no**@nottelling.com> wrote:
" Bruce" <峰; br *** @ nospam.com>在消息中写道
新闻:3f *************** @ news.houston.sbcglobal.net ...
"Bruce" <br***@nospam.com> wrote in message
news:3f***************@news.houston.sbcglobal.net ...
在comp.lang.c ++
JustSomeGuy <无** @ nottelling.com>写道:
In comp.lang.c++
"JustSomeGuy" <no**@nottelling.com> wrote:
>我需要制作一个使用可变数量的onnested> for循环的应用程序。
>
>现在我使用固定数字:
>
> for(z = 0; z< Z; ++ z)
> for(y = 0; y> for(x = 0; x< X; ++ x)
>
>
>事情是可能需要更少或更多的嵌套循环。
>我怎么写这个for循环的数量是一个变量?
>I have a need to make an applicaiton that uses a variable number ofnested >for loops.
>
>for now I''m using a fixed number:
>
>for (z=0; z < Z; ++z)
> for (y=0; y < Y; ++y)
> for (x=0; x < X; ++x)
>
>
>The thing is there could be less or more nested loops necessary.
>How can I write this such that the number of for loops is a variable?
什么是更大的?你试图解决的问题? 20多年来,
我从来不需要做你正在做的事情。
What is the "larger" problem you are trying to solve? In over 20 years,
I''ve never needed to do what you''re doing.
N维数学。
N dimensional math.
尝试更具体。给出一个问题的具体例子
似乎你需要一个可变数量的循环。大多数此类情况
不适合直接(简单的)实施计算机
计划,因为步数极多和/或非常
通常涉及的大值;例如,查看Ackermann的函数
(这也说明了实现循环动态嵌套的一种方法)。
Hth。
- Alf
Try to be more concrete. Give a concrete example of a problem where
it seems that you need a variable number of loops. Most such cases
are not amenable to direct (simple-minded) implementation as computer
programs, due to the extremely large number of steps and/or extremely
large values typically involved; e.g., check out Ackermann''s function
(which also illustrates one way of achieving dynamic nesting of loops).
Hth.
- Alf
这篇关于一个关于嵌套for循环的问题..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!