C++.random
#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;
}
};
浙公网安备 33010602011771号