急求的演算法,vb或者vbs

2023-01-20 03:45:36 字數 753 閱讀 7592

1樓:匿名使用者

rem 公式:用π/4=1-1/3+1/5-1/7+...,級數求π的近似值

private sub form_click()dim s as double, pi as double, i as double

s = 0

for i = 1 to 100000 '上限越大,π的精度越高s = s + 1 / (2 * i - 1) * (-1) ^ (i + 1)

next

pi = 4 * s

print "π="; pi

end sub

2樓:匿名使用者

用for語句,內容可有可無、

s=1for i = 1 to

s=s*fun(i) 'fun()對應π中的解析式[ doevents '這個是防卡死的,想想也知道連乘是多麼的複雜……

'可以另外加的command1來中途取消,比如設定一個全域性變數'cancel為true

if cancel then

cancel=false

exit for

end if ]

next

print s

當然你要另外定義fun(),比如

function fun(a as single)fun=i+2

end function

用的是vb

3樓:匿名使用者

這個要用高等數學微積分啊~

幫我寫vb程式,或者vbs指令碼也行,建立登錄檔項並寫入內容

vbs指令碼寫入登錄檔 set ws createobject wscript.shell ws.regwrite 項路徑 子鍵名 鍵值 鍵值資料 鍵值型別 例 ws.regwrite hkey classes root hkcr.ensp enspfile 123.exe reg sz 在hkcr...

VB程式設計急求,急求VB程式設計程式碼!!!!

private sub command1 click 計算應發工資,text4 text4 val text1 val text2 val text3 計算個人所得稅,text5 if val text4 1000 thentext5 0 elseif val text4 1000 and val ...

急求VB程式設計

呵呵,估計只有這裡題目會是 1000萬 因為這樣就溢位了,並且老師上課是按1000演示的,我這裡也是1000記錄的。老師筆記 是按1000來的 private sub command1 click dim n,pingfang,diwei as doublefor k 3 to 1000 pingf...