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;
	}
};
posted @ 2020-03-16 22:15  N.everever  阅读(293)  评论(0)    收藏  举报