- rand() //产生随机数
- srand() //获得随机数种子
一般用法:
#include <time.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
srand((unsigned int) time(NULL));
for (int i = 0; i < 10; ++i) {
cout<<rand() % 100 <<endl;
}
return 0;
}
参考:
https://www.cnblogs.com/VVingerfly/p/5990714.html