随机数生成器
int _tmain(int /*argc*/, _TCHAR* /*argv[]*/) { struct __timeb64 ftime_timeb; _ftime64_s(&(ftime_timeb)); //time_t time_tmp = ftime_timeb.time; int i_tmp = ftime_timeb.time % 0x7FFFFFFF; srand(i_tmp); map<int, int> temp; for (int i = 0; i < 3000; i++) { int k = rand() % 29; temp[k]++; } for (auto& i : temp) { printf("%d\t%d\n", i.first, i.second); } // 主线程挂起 for (;;) { getchar(); } }
生成数据分析: 因为是3000次,0-29数据出现的次数均分在 100左右,均分。