嵌套的同时 - 如何进入第一次的开始? [英] nested while - how to go to the beginning of the first while?

查看:53
本文介绍了嵌套的同时 - 如何进入第一次的开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个嵌套的同时。我如何从内在的时间到外面的

开始?可以不使用goto吗?


while_1()

{

这里有些代码

while_2()

{

如果为真,则转到while_1的开头

}

这里的一些代码

}

I have a nested while. How do I go from the inner while to the
beginning of the outer while? Can this be done without using goto?

while_1()
{
some codes here
while_2()
{
if true go to the beginning of while_1
}
some codes here
}

推荐答案



invni写道:


invni wrote:
我有一个嵌套的时候。我如何从内在的同时走向外在的开始?
我不想告诉你如何。

这可以在不使用goto的情况下完成吗?
I have a nested while. How do I go from the inner while to the
beginning of the outer while? I would hate to tell you how.
Can this be done without using goto?




你是什么意思?你在开玩笑吗?我从来没有遇到过方言



C给你while_#sort of keywords.Better发布一些真实的,

可编译代码,我们可以讨价还价。大多数代码都渴望获得一个

goto,

需要一个严肃的手术。


[垃圾车只是把你的代码带走了...]


您可能会发现以下文章得心应手:
http://groups.google.co.in/group/com....c/browse_frm/


thread / 1f70380413394ff7 / 09a791583ae54898?q = goto& rnum = 1& hl = en#09a791583ae54 898

Suman。



What do you mean? Are you kidding? I have never come across a dialect
of
C that gives you while_# sort of keywords.Better post some real,
compile-able code, and we can bargain.Most often code that craves for a
goto,
needs a serious surgery.

[the garbage van just took your code away...]

You might find the following article handy:
http://groups.google.co.in/group/com....c/browse_frm/

thread/1f70380413394ff7/09a791583ae54898?q=goto&rnum=1&hl=en#09a791583ae54 898

Suman.


2005年6月25日星期六05:12:16 -0400,invni< in *** @ ms37.hinet.net>

写道:
On Sat, 25 Jun 2005 05:12:16 -0400, invni <in***@ms37.hinet.net>
wrote:
我有一个嵌套的同时。我如何从内在的同时走向外在的开始?这可以在不使用goto的情况下完成吗?

while_1()
{
一些代码在这里
while_2()
{
如果是真的去到while_1的开头
}
这里的一些代码
}
I have a nested while. How do I go from the inner while to the
beginning of the outer while? Can this be done without using goto?

while_1()
{
some codes here
while_2()
{
if true go to the beginning of while_1
}
some codes here
}




假设上面是伪代码,我怀疑你可以使用

休息和继续的组合。这是一个简单的样本,

根据名为ch的char变量和

计数器的值做出决定。


int main(void)

{

char ch =''Y'';

int counter = 0;

while(ch ==''Y'')

{

puts(外循环开始);

而(true)

{

puts(内循环开始);

if(ch ==''N'')

休息;

其他

ch =''N'';

puts(" End of inner循环);

}

if(ch ==''N'')

{

if (计数器++ == 0)

ch =''Y'';

继续;

}

puts (外循环结束);


}

printf(再见\\ n \\ n);

}


输出:

外循环的开始

内循环的开始

结束内循环

内循环的开始

外循环的开始

内循环的开始

内循环结束

内循环的开始

再见


请注意,它从内循环开始跳到开头

of外循环。 HTH。

-


祝福,

Bob



Assuming the above is pseudocode, I suspect that you could use a
combination of break and continue. Here is a trivial sample that
makes decisions based on the value of a char variable named ch and a
counter.

int main(void)
{
char ch = ''Y'';
int counter = 0;
while(ch == ''Y'')
{
puts("Beginning of outer loop");
while(true)
{
puts("Beginning of inner loop");
if(ch == ''N'')
break;
else
ch = ''N'';
puts("End of inner loop");
}
if(ch == ''N'')
{
if(counter++ == 0)
ch = ''Y'';
continue;
}
puts("End of outer loop");

}
printf("Good-bye\n");
}

Output:
Beginning of outer loop
Beginning of inner loop
End of inner loop
Beginning of inner loop
Beginning of outer loop
Beginning of inner loop
End of inner loop
Beginning of inner loop
Good-bye

Note that it skips from beginning of the inner loop to the beginning
of the outer loop. HTH.
--

Best wishes,

Bob


Robert W Hand写道:
Robert W Hand wrote:
2005年6月25日星期六05:12:16 -0400,invni< in *** @ ms37.hinet.net>
写道:

On Sat, 25 Jun 2005 05:12:16 -0400, invni <in***@ms37.hinet.net>
wrote:

我有一个嵌套的同时。我如何从内在的同时走向外在的开始?这可以在不使用goto的情况下完成吗?

while_1()
{
一些代码在这里
while_2()
{
如果是真的去到while_1的开头
}
这里的一些代码
}
I have a nested while. How do I go from the inner while to the
beginning of the outer while? Can this be done without using goto?

while_1()
{
some codes here
while_2()
{
if true go to the beginning of while_1
}
some codes here
}



假设上面是伪代码,我怀疑你可以使用
休息和继续的组合。这是一个简单的样本,它根据名为ch和
计数器的char变量的值做出决定。

int main(void)
{
char ch =''Y'';
int counter = 0;
while(ch ==''Y'')
{
puts(" Beginning of外循环);
while(true)
{
puts(内循环的开始);
if(ch ==''N'')
break;

ch =''N'';
put(内循环结束);
}
if(ch == ''N'')
{
if(counter ++ == 0)
ch =''Y'';
继续;
}
把(外循环结束);

}
printf(再见);
}
输出:
外循环的开始
内循环的开始
内循环的结束
Beginnin g。内圈
外圈开始
内圈开始
内圈结束
内圈开始
再见

>请注意,它从内循环的开头跳到外循环的开头。 HTH。


Assuming the above is pseudocode, I suspect that you could use a
combination of break and continue. Here is a trivial sample that
makes decisions based on the value of a char variable named ch and a
counter.

int main(void)
{
char ch = ''Y'';
int counter = 0;
while(ch == ''Y'')
{
puts("Beginning of outer loop");
while(true)
{
puts("Beginning of inner loop");
if(ch == ''N'')
break;
else
ch = ''N'';
puts("End of inner loop");
}
if(ch == ''N'')
{
if(counter++ == 0)
ch = ''Y'';
continue;
}
puts("End of outer loop");

}
printf("Good-bye\n");
}

Output:
Beginning of outer loop
Beginning of inner loop
End of inner loop
Beginning of inner loop
Beginning of outer loop
Beginning of inner loop
End of inner loop
Beginning of inner loop
Good-bye

Note that it skips from beginning of the inner loop to the beginning
of the outer loop. HTH.




我明白了。谢谢。



I got the idea. Thanks.


这篇关于嵌套的同时 - 如何进入第一次的开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆