程式设计oC语言.ppt

程式设计oC语言.ppt

程式設計II 迴圈控制 For迴圈 for([datatype]counter=start;停止條件:counter+/-=step) { 程式本體; } While迴圈 do…while迴圈 Do{ 程式本體; }while(條件); 巢狀迴圈 For(…) 第一層迴圈 { 程式本體1; for(…) 第二層迴圈 { 程式本體2; } } 離開迴圈 Continue(1) int i,x=0; for(i=0;i3;i++){ x=i++; continue; x=i*I; } Continue(2) int x,i=0; do { x=i++; continue; x=i*I; }while(i3); Continue(3) Int x,i=5; while(i0) { x=i; if(x==1) continue; i--; } 迴路敘述 (重複執行) for ( ; ; ){ … } while { … } do { … } while (…); for敘述 for的敘述 是最常見的迴路敘述, 其特性在於可以有彈性的控制迴路的執行次數 for的語法 for(

文档评论(0)

1亿VIP精品文档

相关文档