016 生成随机数

 

 

#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;
}

 

posted @ 2019-09-19 22:45  火焰马  阅读(172)  评论(0编辑  收藏  举报