C++中随机函数

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

int main()
{
    int i;
    srand((unsigned)time(NULL)); //初始化随机数种子
    for (i=0; i<10; i++)         //产生10个随机数
    {
        cout<<rand()<<"/t";
    }
    cout<<endl;
    return 0;
}

你可能感兴趣的:(C++)