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

📄 rand_.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
字号:
#ifndef lint static	char sccsid[] = "@(#)rand_.c 1.1 92/07/30 SMI"; /* from UCB 1.1" */#endif/* * * Routines to return random values * * calling sequence: *	double precision d, drand *	i = irand(iflag) *	x = rand(iflag) *	d = drand(iflag) * where: *	If arg is 1, generator is restarted. If arg is 0, next value *	is returned. Any other arg is a new seed for the generator. *	Integer values will range from 0 thru 2147483647. *	Real values will range from 0.0 thru 1.0 *	(see random(3)) */#include <math.h>#define	RANDMAX		2147483647#define		STATESIZE	256char	*initstate();char	state[STATESIZE];long irand_(iarg)long *iarg;{	if (*iarg) initstate( (unsigned) *iarg,state,STATESIZE);	return( random() );}FLOATFUNCTIONTYPErand_(iarg)long *iarg;{	float result;	if (*iarg) initstate( (unsigned) *iarg,state,STATESIZE);	result = (float) ( ((double)random())  / ( (double)RANDMAX ) );	RETURNFLOAT(result);}double drand_(iarg)long *iarg;{	if (*iarg) initstate( (unsigned) *iarg,state,STATESIZE);	return( (double)(random())/(double)RANDMAX );}

⌨️ 快捷键说明

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