Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Viewed less than a minute ago

8K0G5iQN7f5A8TTi

C gcc 12.1.0

Created at 8 minutes ago

Created by anonymous

Author

anonymous

8 minutes ago

Language

C

Compiler

gcc 12.1.0

Options
Warnings
Optimization
C99
-pedantic
Raw compiler options
-Dscanfs=scanf
セオライド・テクノロジー㈱株式会社フィックスターズ
Siv3D

Author

anonymous

8 minutes ago

›
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81


#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int main() {

double i, p, r, a, b = 0, girl, boy;
srand((unsigned int)time(NULL));

printf(" 0 < p < 10000の範囲でpの値を入力してください\n");
scanfs("p = %lf", &p);

p = p / 10000;

for (i = 0; i < 10000; i++) {

r = (double)rand() / RAND_MAX;

boy = 0;
girl = 0;

if (p > r) {

girl++;

}
else {

boy++;

}
if (girl == 0) {

while (boy < 2) {

r = (double)rand() / RAND_MAX;

if (p > r) {

girl++;

}
else {

boy++;

}
}
}
else if (girl == 1) {

while (girl < 2) {

r = (double)rand() / RAND_MAX;

if (p > r) {

girl++;

}
else {

boy++;

}
}
}

a = boy + girl;
b = b + a;

}

b = b / 100;
printf("子供の平均の数 = %f\n", b);

return 0;

}
›
9
1
p = 314
$ gcc prog.c -Wall -Wextra -O2 -march=native -std=c99 -pedantic -Dscanfs=scanf
 0 < p < 10000の範囲でpの値を入力してください
子供の平均の数 = 293.660000
Exit Code:
0
セオライド・テクノロジー㈱株式会社フィックスターズ
Siv3D