每當我運行下面的程序返回的值始終爲6或13蘭特()%14只產生了6值或13
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>
using namespace std;
//void randomLegs();
//void randomPush();
//void randomPull();
//void randomMisc();
int main(int argc, const char * argv[])
{
srand(time(NULL));
//randomLegs();
cout << rand() % 14;
return 0;
}
我今天在運行程序的近百次,昨天。
誰能告訴我我做錯了什麼?
謝謝。
編輯:順便說一句,如果我更改rand()的範圍說13或15它工作得很好。
如果您有超出'rand'保證滿足的特定要求,請勿使用'rand'。 –