gauss.c

来自「包括了产生随机数的代码、并且同时利用随机数的程序产生正态随机分布函数」· C语言 代码 · 共 29 行

C
29
字号
 #include <stdlib.h> 
 #include <iostream.h> 
 #include <conio.h> 
 #include <time.h> 
 #include <stdio.h>
 #include <math.h> 
double  Gauss(double m,double s)   
    {   
    double  n=0,gaussway; 
	int i;
	srand((unsigned)time(NULL)); 
    for(i=0;i<12;i++)   
    {  
	  n+=(double)rand()/RAND_MAX;   
    }   
    n=n-6; //标准化 
	gaussway=m+sqrt(s)*n;
    return gaussway;   
    }   
    main()
	{double x=6,y=1,z;
    double Gauss(double m,double s);
    z=Gauss(x,y);
	printf("%f",z);
	}


     

⌨️ 快捷键说明

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