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

📄 random walk process.cpp

📁 walk random process programmed in visual c++ 0.6
💻 CPP
字号:
#include "iostream.h"
#include "windows.h"
#include "math.h"

int n;
int Exp;
float xx=0;
float yy=0;
float *d=new float (Exp);
float *xx1=new float (n);
float *yy1=new float (n);


void main()
{
	float R,theta;
	cout<<"Enter number of repeating experiment\n";
	cin>>Exp;
	cout<<"Enter N\n";
	cin>>n;
	cout<<"_________________________________\n";
	for(int i=0;i<Exp;i++)
	{
		xx=0;
		yy=0;
		for(int j=0;j<n;j++)
		{
			R=(float)rand() / RAND_MAX ;
			theta=360*R;
			xx=xx+cos (theta*3.14/180);
			xx1[j]=10*xx;
			yy=yy+sin (theta*3.14/180);
			yy1[j]=10*yy;
		}
		d[i]=sqrt(pow(xx,2)+pow(yy,2));
		cout<<"d"<<i+1<<"= "<<d[i]<<endl;
	}
	
}

⌨️ 快捷键说明

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