break的使用for循環嵌套

 1 /*
 2   Name:break的使用for循環嵌套 
 3   Copyright: By.不懂網絡
 4   Author: Yangbin
 5   Date:2014年2月21日 02:54:04 
 6   Description:如下代碼無任何實際含義,只爲熟悉瞭解break語句的使用。 
 7 */
 8 # include <stdio.h>
 9 int main(void)
10 {
11     int i,j;
12     for(i=0;i<3;++i)
13     {
14         for(j=2;j<5;++j)
15         break; //break語句只能終止離該語句最近的循環 
16         printf("我會被輸出3次嗎?\n");
17     }
18 }
19 
20 /*
21 ----------------------
22 該代碼由C-Free 5.0 編寫並輸出調試結果
23 ------------輸出結果-------------
24  我會被輸出3次嗎?
25 我會被輸出3次嗎?
26 我會被輸出3次嗎?
27 ---------------------------
28 總結:
29 break語句只能終止離他最近的循環,因此printf輸出3次。 
30 
31 */
相關文章
相關標籤/搜索