#include<random>
#include<iostream>
#include<time.h>
using namespace std;
int main()
{
default_random_engine dre;
dre.seed((unsigned)time(NULL));
int i = 10;
while(i--)cout << dre()%9 << endl;
cout << endl;
uniform_int_distribution<unsigned> inum(0, 10);
i = 10;
while(i--) cout << inum(dre)<< endl;
uniform_real_distribution<double> rnum(0.0, 10.0);
cout << endl;
i = 10;
while (i--) cout <<rnum(dre) << endl;
system("pause");
return 0;
}
运行结果:
详细及更多用法参见http://www.cplusplus.com/