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

📄 frand.c

📁 国外网站上的一些精典的C程序
💻 C
字号:
/***  FRAND.C - Public domain by Larry Hudson*/#include <math.h>#include <time.h>#include "snipmath.h"#define TEN_PI 31.41592653589793#define E      2.718281828459045/*--------------------------------------------------------------+|           Return random double between 0.0 and 1.0            ||                                                               ||    If n is negative it will randomize the seed, based on the  ||        current MSDOS time.                                    ||    If n is zero it will return the next random number.        ||    If n is positive it will set the seed to a value based on  ||        the value of n.                                        |+--------------------------------------------------------------*/double frandom(int n){      static double seed = E;      double dummy;      time_t tim;      if (n < 0)      {            time(&tim);            seed = (double)tim;      }      else if (n > 0)            seed = (double)n * E;      seed = modf(seed * TEN_PI + E, &dummy);      return seed;}

⌨️ 快捷键说明

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