c++高级编程

std::normal_distribution<double> dis1(0, 1);
	std::default_random_engine random(time(NULL));
	for(i=0;i<10;i++)
	std::cout<<dis1(random)<<",";

 这个一个正态分布函数,Mean of the distribution (its expected value, μ).,Standard deviation (σ)




 
 

结论:

     随机变量的分布X在[-3σ,3σ]的概率比较大,所以大部分分布在这个区域内,但是会有少数值在这个之外。

 

使用c++进行字符串和数字转换

for example,

#include<sstream>
#include<string>
using namespace std;
int main(){
     int auNum;   
     string str="123";
     char n[]="564";      
     std::stringstream s(str);
      s>>auNum;

    sscanf(n,"%d",&auNum);//
    return 0;
}

猜你喜欢

转载自435727748.iteye.com/blog/2357598