_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › 覈豺企ゼ襦覯朱譯殊蟲蠍

Contents

1 覓語
2 T-SQL襦 蟲
3 谿瑚襭


1 覓語 #

覦讌襴 100 .
螳襯 蠏語 1/4 碁ゼ 襷. (2覿覃)
2螳(x,y)襯 覦貅 0朱覿 碁ゼ 覯企讌 覯企讌 讌襯 譬襯 谿.
狩螻殊 襴 x^2 + y^2 = z^2 企蟾 sqrt(z^2) 覃 朱覿 100 願讌 願讌 .
企ゼ 10000 覦覲牛 豢 譯殊 蟲.

pi.png


2 T-SQL襦 蟲 #

declare 
    @i int
,   @x float
,   @y float
,   @r int
,   @in_count float
,   @out_count float

set @r = 100
set @i = 1
set @in_count = 0
set @out_count = 0

while(@i <= 10000)
begin
    set @x = rand() * @r
    set @y = rand() * @r
    if sqrt(@x*@x + @y*@y) > @r 
        set @out_count += 1
    else
        set @in_count += 1

    set @i += 1
end

print @in_count/@i * 4 --2覿覃企 朱襦 4襯 螻燕伎.

3.16128 .
磯Μ螳 螻 pi螳 3.141592 觜る企Μ.
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

螳 蟾 螳 豺覓 . (襷 覓伎)