📄 main6.cpp.txt
字号:
// 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 + -