utils.h
来自「在WINDOWS环境下用C语言开发的寻路程序」· C头文件 代码 · 共 48 行
H
48 行
#ifndef UTILS_H
#define UTILS_H
/////////////////////////////////////////////////////////////////////////
//
// File: Utils.h
//
// Author: Mat Buckland
//
// Desc: useful utilities
//
/////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <math.h>
#include <sstream>
#include <string>
using namespace std;
//-----------------------------------------------------------------------
// some random number functions.
//-----------------------------------------------------------------------
inline int RandInt(int x,int y) {return rand()%(y-x+1)+x;}
inline double RandFloat() {return (rand())/(RAND_MAX+1.0);}
inline bool RandBool()
{
if (RandInt(0,1)) return true;
else return false;
}
//returns a random float in the range -1 < n < 1
inline double RandomClamped() {return RandFloat() - RandFloat();}
//-----------------------------------------------------------------------
// useful string functions
//-----------------------------------------------------------------------
//int to string function
string itos(int arg);
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?