每当我运行以下程序时,返回的值总是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;
}
Run Code Online (Sandbox Code Playgroud)
在今天和昨天,我已经将程序运行了近百次.
谁能告诉我我做错了什么?
谢谢.
编辑:顺便说一句,如果我将rand()的范围改为13或15,它就可以了.