#include "time.h" #include "windows.h" int random(int max_range = 1) { if (max_range == 1) return rand() << 16 | rand(); return (rand() << 16 | rand()) % max_range; } int _tmain(int argc, _TCHAR* argv[]) { srand((unsigned int)time(NULL)); //Just use once at startup for random() printf("Randoms: %08X %08X %08X \n", random(), random(), random(1000)); return 0; } //reference: http://www.zhihu.com/question/24297923
C/C++获取整型随机数
最新推荐文章于 2024-06-07 15:54:06 发布