C++获取随机数(伪随机数)

#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;

int main()
{
	int i,j;
	//设置种子;
	srand((unsigned)time(NULL));
	for(i=0;i<10;i++)
	{
		j=rand();
		cout<<"随机数: "<<j<<endl;
	}
	return 0;
}

  

posted on 2018-05-03 17:58  Cherish丶  阅读(763)  评论(0)    收藏  举报

导航