[๐ฌ]
๊ตฌ๊ธ ๋ฌธ์ ๋ฐ๋ก ์ง ์ฝ๋๋ก ๊ฒ์ฆ
์ต๋ช
(119.207)
2022-05-23 16:18
์ถ์ฒ 1
using System
.Collections
.Generic
;
using System
.Linq
;
using UnityEngine
;
public class fuck_googlemath
: MonoBehaviour
{
public int familyCnt
= 1000000;
private List
<Children
> family
= new List<Children>();
void Start()
{
for (int f
= 0; f
< familyCnt
; f
++)
{
bool produce
= true;
var fam
= new Children();
while (produce
)
{
var rnd
= Random
.Range(0, 1f);
if (rnd
> 0.5) fam
.boy
++;
else fam
.girl
++;
if (fam
.boy
> 0) produce
= false;
}
family
.Add(fam
);
}
float boyCnt
= family
.Sum(x
=> x
.boy
);
float girlCnt
= family
.Sum(x
=> x
.girl
);
print($
"boy = {boyCnt} : girl = {girlCnt} ? {boyCnt / girlCnt}");
}
}
public class Children
{
public int boy
;
public int girl
;
}
๊ฑ ๋๋ ค๋ด...
๊ณ์ฐ์ ์ฝคํจํ๊ฐ ํ๋๊ฒ ๋ง๋ค....
์ค ์ด๊ฑฐ ์ฌ๋ฐ๊ฒ ๋ค ์ง๊ธ๋น์ฅ ๋ง๋ค์ด์ ํ ์คํธํด๋ด์ผ๊ฒ ๋ค
์ฌ์๋ฉด ๋ฐ๋ณต์ด๊ณ ๋จ์๋ฉด ๋ฐ๋ณต๋๋๋๊น ์ฌ์ =1, ๋จ์=0 ํด์ ๋ฐ๋ณต๋ฌธ ๋ฃ์ผ๋ฉด ๋ ๋ฏ