?? random.cpp
字號:
// ============================================================================
// Random
//
// Return a random number within the specified range
//
// (c) 2003 Ken Reed
//
// This is free software. You can redistribute it and/or modify it under the
// terms of the GNU General Public License version 2 as published by the Free
// Software Foundation.
// ============================================================================
#include "stdafx.h"
#include <stdlib.h>
#include <time.h>
// ============================================================================
// Return double value
// ============================================================================
double random(double minimum, double maximum)
{
static bool first_time = true;
if (first_time) {
srand((int) time(0));
first_time = false;
}
double range = maximum - minimum;
double rval = (double(rand())/RAND_MAX) * range;
rval += minimum;
return rval;
}
// ============================================================================
// Return int value
// ============================================================================
int irandom(int minimum, int maximum)
{
return static_cast<int>(random(minimum, maximum));
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -