【C++】随机数的产生

利用时钟产生随机数

包含头文件,产生30~47的随机数

#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;

int main()
{
    srand((unsigned)time(NULL));
    for(int i =0; i < 100; i++)
    {
        cout << rand() % 17 +30 << " ";
    }
    return 0;
}
记录点点滴滴
原文地址:https://www.cnblogs.com/1by1/p/10858807.html