打破嵌套循环嵌套

由网友(Get rid of挣脱)分享简介:有人可以告诉我如何打破主循环,当我有嵌套循环?例如*:Can someone tell me how to break the main loop when I have nested loops?Example*:/*Main loop*/for(int y = 0; y < 100; y+=10){/*...

有人可以告诉我如何打破主循环,当我有嵌套循环? 例如*:

Can someone tell me how to break the main loop when I have nested loops? Example*:

/*Main loop*/
for(int y = 0; y < 100; y+=10)
{
    /*Sub loop*/
    for (int x = 0; x < 100; x += 10)
    {
        if(x == 60) 
        { 
            //Break the main loop 
        }
    }
}

*此code什么也不做,这只是一个例子

*This code do nothing, it's just an example

我应该把在打破主循环的评论的地方吗?在java中有标签,我可以打破(当我设置一个标签,名为主循环我可以写主循环打破主循环,这将是有效的),但我能做些什么位置

What should I put in the place of the "Break main loop" comment? In java there are labels which I can break (when i set a label to the main loop named "MainLoop" I can write "break MainLoop;" and it will be valid), but what can I do here?

谢谢指教!

推荐答案

GOTO

我不明白为什么人们总是说 GOTO 被认为是有害的。很好用的,这是非常强大的,这也是这种情况。

I don't understand why people always say that goto is considered "harmful". Well used, it is very powerful, and this is such a case.

阅读全文

相关推荐

最新文章