int ToolFunc::calcRandom(int starNum,int endNum) { int result = 0; static int count = 0; struct timeval now; if(starNum >= endNum) return 0; gettimeofday(&now,NULL); srand(now.tv_usec + count); count += 1; result = starNum + rand() % (endNum - starNum + 1); return result; }这个是一个闭区间。 原文链接:https://www.f2er.com/cocos2dx/344578.html