本文介紹了我可以使用 break 退出多個嵌套的“for"循環嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
是否可以使用break
函數退出多個嵌套的for
循環?
Is it possible to use the break
function to exit several nested for
loops?
如果是這樣,你會怎么做?你還能控制break
退出多少個循環?
If so, how would you go about doing this? Can you also control how many loops the break
exits?
推薦答案
AFAIK,C++ 不支持命名循環,就像 Java 和其他語言一樣.您可以使用轉到,或創建您使用的標志值.在每個循環結束時檢查標志值.如果它被設置為 true,那么你可以跳出那個迭代.
AFAIK, C++ doesn't support naming loops, like Java and other languages do. You can use a goto, or create a flag value that you use. At the end of each loop check the flag value. If it is set to true, then you can break out of that iteration.
這篇關于我可以使用 break 退出多個嵌套的“for"循環嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!