#include <time.h>
class IntRandom
{
public:
IntRandom()
{
srand((unsigned)time(NULL));
}
int GetInt(int from = 0, int to = 0)
{
int i = rand();
if (to > from)
{
i = from + i % (to - from);
}
else
{
i += from;
}
return i;
}
};
原文:https://www.cnblogs.com/dailycode/p/12507319.html