码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-04-13 22:29:55      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:

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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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

标签:

原文地址:http://www.cnblogs.com/fengkuangIT/p/4423353.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!