如果彼此有3个回路,我怎么能断开到上层回路,我的意思是:

while (abc) {
    for (int dep =0 ; dep<b ; dep++)  {
         for (int jwe=0 ; jwe<g ; jwe++) {
             if (! (ef || hf) ) {
             //here is where i want to break to loop while
             //or in other purpose (other situation) i need
             //to know how i could break to first loop
             //i mean (for (int dep =0 ; dep< b ; dep++)
             }
         }
    }
}

有人能帮帮我吗,如果之后,我可以打破while循环,或者我可以打破第一个循环“for”。

最佳答案

只需将外部循环的计数器设置为一个值,这样它就不会再次运行。

while (abc) {
    for (int dep =0 ; dep<b ; dep++)
    for (int jwe=0 ; jwe<g ; jwe++)
     if (! (ef || hf) ) {
         //here is where you want to break to the while-loop
         //abc = 0; here will make it exit the entire while as well
         dep = b; //in order to exit the first for-loop
         break;
     }
}

关于c - 如何在另一个循环中中断循环,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15180117/

10-11 19:00