freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

第04章控制程序流程(已修改)

2025-03-11 06:18 本頁面
 

【正文】 第 04章控制程序流程 2 本章內(nèi)容安排 ?while循環(huán) ?do~while循環(huán) ?for循環(huán) ?高級循環(huán) ?switch 3 循環(huán)的概念 ?計算機擅長的工作之一是重復做相同的事情。 ?許多編程任務可以通過重復相同的操作來完成,通過指定次數(shù)戒設定條件來控制執(zhí)行過程。多次重復執(zhí)行的結(jié)構(gòu)稱為 循環(huán) ,每一次循環(huán)稱為 迭代 。 ?while、 do~while、 for 4 while循環(huán) ?在指定條件為 true的情況下,程序重復執(zhí)行,直到指定條件變?yōu)?false。 ?條件放在 while之后的()內(nèi),循環(huán)執(zhí)行的語句放在一對{}內(nèi)。 表達式 F 循環(huán)體語句 T while(表達式 ) { 循環(huán)體語句 。 } 5 顯示 0~99 include iostream using namespace std。 int main() { int x=0。 while( x100 ) { cout x 。 x++。 } return 0。 } ?假如循環(huán)語句中沒有 x++,則 while循環(huán) 的條件永遠為真,導致循環(huán)一直執(zhí)行, 稱為無限循環(huán)或死循環(huán)。 6 顯示 0~99,每行 5個 include iostream using namespace std。 int main() { int x=0。 while( x100 ) { cout x 。 x++。 if(x%5==0) coutendl。 } return 0。 } ?遞增 x,每當 x是 5的倍數(shù)時,輸出回車。 7 顯示前 20個整除 14的正整數(shù) include iostream using namespace std。 int main() { int x=0, count=0。 while( true ) { x++。 if(x%14==0) { coutx 。 count++。 } if(count19) break。 } return 0。 } ?循環(huán)中讓 while的條件為 true,構(gòu) 造 1個無限循環(huán)。 ?在循環(huán)體內(nèi),調(diào)用 break語句,可 立即停止循環(huán)的執(zhí)行。 ?使用 while( true )結(jié)構(gòu)時,要確 保循環(huán)能夠停止。 8 顯示前 20個整除 14的正整數(shù) include iostream using namespace std。 int main() { int x=0, count=0。 while( count19 ) { x++。 if(x%15!=0) { continue。 } coutx 。 count++。 } return 0。 } ?在循環(huán)中遇到 continue語句,將 跳過余下的語句,執(zhí)行下一次 迭代。 ?break結(jié)束當前循環(huán),而 continue 結(jié)束本次迭代。 9 顯示前 20個整除 14的正整數(shù) include iostream using namespace std。 int main() { int x=0, count=0。 while( count19 ) { x+=14。 coutx 。 count++。 } return 0。 } ?14倍數(shù),從 14開始,依次遞增 14。 10 本章內(nèi)容安排 ?while循環(huán) ?do~while循環(huán) ?for循環(huán) ?高級循環(huán) ?switch 11 do~while循環(huán) ?while在執(zhí)行循環(huán)前檢查條件,如果此時條件為false,則一次循環(huán)也不執(zhí)行。
點擊復制文檔內(nèi)容
教學課件相關推薦
文庫吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號-1