// 随机数产生.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include<ctime>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i =0 ;
cout<<"产生10个0到100之间的随机数:"<<endl;
srand((unsigned)time(NULL)); //以系统时间作为随机种子
for(i=0;i<10;i++)
{
cout<<rand()%100<< " ";
}
cout<<endl;
cout<<"请输入需要产生m到n之间的随机数的m与n的值:"<<endl;
int m,n;
cin>>m>>n;
cout<<"产生10个 "<<m<<" 到 "<<n<<" 之间的随机数:"<<endl;
srand((unsigned)time(NULL)); //以系统时间作为随机种子
for(i=0;i<10;i++)
{
cout<<m + rand()%(n-m+1)<< " ";
}
cout<<endl;
system("pause");
return 0;
}