随机数 while循环 do while循环 for循环

1、随机数   arc4random()    返回一个随机数

   如果要随机[a,b]范围内的随机数   arc4random() % (b - a + 1) +  a ;

2、break  跳出本次循环

    continue  结束本次循环,continue代码不再执行,进入下次循环。

  

    int n = 1;

    while (n <= 100) {

         if (n == 65) {

             break;

        }

        printf("%d " , n);

        n++;

        }

运行结果 :  1 2 3

    int n = 0;

    while (n <= 6) {

        

        if (n == 4) {

            n++;

            continue;

        }

        printf("%d " , n);

         n++;

       }

 运行结果  : 1 2 3 5  6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
posted @ 2015-04-13 21:35  fengkuangIT  阅读(841)  评论(0编辑  收藏  举报