⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uniform.cpp

📁 以前写的一个bughunt小游戏
💻 CPP
字号:
//**************************************************************************
//
// Copyright (c) 1997.
//      Richard D. Irwin, Inc.
//
// This software may not be distributed further without permission from
// Richard D. Irwin, Inc.
//
// This software is distributed WITHOUT ANY WARRANTY. No claims are made
// as to its functionality or purpose.
//
// Authors: James P. Cohoon and Jack W. Davidson
// Date: 7/15/96
// $Revision: 1.2 $
// $Name: E2 $
//
//**************************************************************************

// Implementation of Randomize and Uniform
#include <stdlib.h>
#include <iostream>
#include <string>
#include <time.h>
#include "uniform.h"

using namespace std;

// Randomize(): set the random number generator seed
void InitializeSeed() {
	srand((unsigned) time(0));
}

// Uniform(): generate a uniformly distributed random 
// number between Low and High
int Uniform(int Low, int High) {
	if (Low > High) {
		cerr << "Illegal range passed to Uniform\n";
		exit(1);
		return 0; // Makes MS C++ shut up
	}
	else {
		int IntervalSize = High - Low + 1;
		int RandomOffset = rand() % IntervalSize;
		return Low + RandomOffset;
	}
}

⌨️ 快捷键说明

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