智慧 + 毅力 = 无所不能

正确性、健壮性、可靠性、效率、易用性、可读性、可复用性、兼容性、可移植性...

导航

C++中随机函数

Posted on 2013-06-25 12:51  Bill Yuan  阅读(346)  评论(0编辑  收藏  举报
#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;
}