Introduction to mt19937

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int a[1000];
 4 mt19937 mt_rand(time(0));
 5 
 6 int main() {
 7     cout << mt_rand() << endl;//生成一个随机数
 8     int n;
 9     scanf("%d",&n);
10     for(int i=1;i<=n;i++) a[i]=i;
11     shuffle(a+1, a+1+ n, mt_rand); // The shuffle () function randomly shuffles all characters in the string 
12      for ( int i = 1 ; i <= n; i ++) printf ( " % d \ n " , a [i] );
 13      return  0 ;
 14 }

 

Guess you like

Origin www.cnblogs.com/wsy107316/p/12709818.html