dice.cpp

来自「为大家搜集免费的计算机学习、编程资料和优秀的网络资源。多多支持」· C++ 代码 · 共 24 行

CPP
24
字号
#include "Dice.h"

// function used to seed the random number generator

// one possible side-effect of this is if a program creates it's first Dice object after it
// has set the seed to a particular value, the random number generator will be reseeded to
// a different (except in the fluke wild chance that the numbers match)
void InitializeRandomizer()
{
	// used to determine if srand has already been run once
	// since it is static it will remain the same for as long as the program runs
	static bool initialized = false;

	// if it hasn't been initialized, do so now
	if(! initialized)
	{
		// this function initializes the random number generator
		srand( (unsigned)time( NULL ) );

		// set initialized to true to prevent further initializations
		initialized = true;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?