·思想:srand()提供种子,rand()产生很大的随机数。
#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
srand(1);
for (int i = 0; i < 10; i++)
cout << rand() << '\t';
cout << endl;
return 0;
}
·time作为种子:
#include <time.h>
srand((unsigned)time(NULL));