[問題] 請問 rand()出來的數值都在固定範圍??
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
DEV C++
想請問一下我用 rand()產生的值都在固定 12xxx左右
這是怎麼回事
他不是應該 0~32767?
我一開始有用 srand(time(NULL))
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
int main(void)
{
srand(time(NULL));
printf("%d",rand());
system("pause");
return 0;
}
--
每次跑都會在差不多的數值左右??
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 1.142.132.170
推
06/06 18:48, , 1F
06/06 18:48, 1F
→
06/06 18:50, , 2F
06/06 18:50, 2F
→
06/06 18:51, , 3F
06/06 18:51, 3F
※ 編輯: tobashi 來自: 1.142.132.170 (06/06 18:54)
※ 編輯: tobashi 來自: 1.142.132.170 (06/06 18:54)
→
06/06 19:30, , 4F
06/06 19:30, 4F
→
06/06 19:50, , 5F
06/06 19:50, 5F
→
06/11 15:20, , 6F
06/11 15:20, 6F