[ create a new paste ] login | about

Link: http://codepad.org/Nkh1TwRl    [ raw code | fork ]

C++, pasted on May 25:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
double napier(int n) {
	int box[CNTS];
	for(int i = 0; i < CNTS; i ++) { // 箱を1で初期化
		box[i] = 1;
	}
	int cnt = 0;
	int j;
	for(int i = 0; i < CNTS; i ++) {
		j = (int) CNTS * genrand_res53(); // 入る箱の番号
		box[j] = 0;
	}
	for(int i = 0; i < CNTS; i ++) { // 残った箱をカウント
		cnt += box[i];
	}

	double napier = (double) CNTS / cnt;
	return napier;
}


Create a new paste based on this one


Comments: