random generator demo(Law of Large Numbers)

来源:互联网 发布:缠通套利指标源码破解 编辑:程序博客网 时间:2024/06/07 14:01
#include <iostream>#include "random.h"using namespace std;int main(){Randomize();cout << "This program averages a series of random numbers\n" << "between 0 and 1." << endl;cout << "How many trials: ";int n;cin >> n;double sum = 0.0;for (int i = 0; i < n; i++) {sum += RandomReal(0, 1);}cout << "The average value after " << n << " trials is "  << sum / n << endl;return 0;}

0 0
原创粉丝点击