How to break out of nested loops?

前端 未结 15 2628
北荒
北荒 2020-11-27 11:21

If I use a break statement, it will only break inner loop and I need to use some flag to break the outer loop. But if there are many nested loops, the code will

15条回答
  •  情深已故
    2020-11-27 12:15

    for(int i = 0; i < 1000; i++) {
       for(int j = 0; j < 1000; i++) {
           if(condition) {
                goto end;
       }
    } 
    
    end:
    

提交回复
热议问题