?? random-simulation-2.cpp
字號:
// Monte Carlo Simulation
// Written by Microsoft Visual C++
// Copyright by UTLab @ Tsinghua University
// http://orsc.edu.cn/UTLab
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "UTLab.h"
main()
{
int i, k=0, n=3000;
double a, b, c;
for(i=1; i<=n; i++) {
a=myexp(1);
b=myn(2,1);
c=myu(0,3);
if((a+b*b+c*c*c)<=30) k++;
}
printf("L = %3.4f\n",(double)k/n);
return 1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -