首页 > 其他 > 详细

016 生成随机数

时间:2019-09-20 02:14:16      阅读:79      评论:0      收藏:0      [点我收藏+]

 

 

#include "stdafx.h"
#include <stdlib.h>
#include <time.h>

// 生成随机数 - 100到200
int main(int argc, char *argv[], char **envp)
{
    srand((unsigned)time(NULL));

    int nLoop = 0;
    while (nLoop < 20)
    {
        int i = 100 + rand() % 100;
        printf("%d\n", i);

        ++nLoop;
    }

    return 0;
}

 

016 生成随机数

原文:https://www.cnblogs.com/huafan/p/11553108.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!