經(jīng)典vb編程題

經(jīng)典vb編程題

ID:20933004

大?。?42.21 KB

頁數(shù):20頁

時間:2018-10-18

經(jīng)典vb編程題_第1頁
經(jīng)典vb編程題_第2頁
經(jīng)典vb編程題_第3頁
經(jīng)典vb編程題_第4頁
經(jīng)典vb編程題_第5頁
資源描述:

《經(jīng)典vb編程題》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在行業(yè)資料-天天文庫。

1、1.Fibonacci函數(shù)。PrivateSubCommand1_Click()DimnAsIntegern=Text1Text2=fib(n)EndSubFunctionfib(ByValxAsInteger)AsIntegerIfx=1Orx=2Thenfib=1Elsefib=fib(x-2)+fib(x-1)EndIfEndFunctionPrivateSubCommand2_Click()Text1=""Text2=""Text1.SetFocusEndSubPrivateSubCommand3_Click()EndEndSub2.

2、百元百雞PrivateSubcmdCalc_Click()'變量說明DimxAsIntegerDimyAsIntegerDimzAsInteger'窮舉法計算Forx=1To20Fory=1To33z=100-x-yIf5*x+3*y+z/3=100ThenText1=Text1&CStr(x)&Space(6)&CStr(y)&Space(6)&CStr(z)&Chr(13)&Chr(10)EndIfNextyNextxEndSub3.矩陣不靠邊元素和Forj=1To5a(i,j)=Int(Rnd*90)+10NextNextFori=1T

3、o5Forj=1To5Picture1.Printa(i,j);NextPicture1.PrintNextEndSubPrivateSubCommand2_Click()Text1=fun1(a)EndSubFunctionfun1(x()AsInteger)AsDoubleDimiAsInteger,jAsIntegerfun1=0Fori=LBound(x,1)ToUBound(x,1)Forj=LBound(x,2)ToUBound(x,2)IfNot(i=LBound(x,1)Ori=UBound(x,1)Orj=LBound(x,

4、2)Orj=UBound(x,2))Thenfun1=fun1+x(i,j)EndIfNextNextEndFunctionPrivateSubCommand3_Click()Text1=""Picture1.ClsCommand1.SetFocusEndSubPrivateSubCommand4_Click()EndEndSub4.遞歸函數(shù)PrivateSubCommand1_Click()List1.ClearDimiAsIntegerFori=1To7List1.AddItemfact(i)NextiEndSubFunctionfact

5、(ByValnAsDouble)AsDoubleIfn=1Thenfact=1Elsefact=n*fact(n-1)EndIfEndFunctionPrivateSubCommand2_Click()List1.ClearEndSubPrivateSubCommand3_Click()EndEndSub5.回文數(shù)PrivateSubCommand1_Click()RandomizeDimiAsInteger,xAsInteger,minAsIntegerFori=1To500x=Int(Rnd*9000)+1000Text1=Text1&x

6、&vbCrLfIfHuiWenShu(x)ThenText2=Text2&x&vbCrLfIfmin=0Thenmin=xElseIfmin>xThenmin=xEndIfEndIfEndIfNextiText3=minEndSubFunctionHuiWenShu(ByValaAsInteger)AsBooleanIfStrReverse(a)=aThenHuiWenShu=TrueElseHuiWenShu=FalseEndIfEndFunctionPrivateSubCommand2_Click()Text1=""Text2=""Tex

7、t3=""EndSubPrivateSubCommand3_Click()EndEndSub6.級數(shù)求和。PrivateSubCommand1_Click()DimsAsDouble,nAsLongDimmAsDoubles=0n=1Dom=1/(2*n-1)Ifm<10^(-5)ThenExitDos=s+mn=n+1LoopText1=CStr(s)EndSubPrivateSubCommand2_Click()Text1=""EndSubPrivateSubCommand3_Click()EndEndSub7.矩陣轉(zhuǎn)置OptionBas

8、e1Dima(4,4)AsIntegerPrivateSubCommand1_Click()DimbAsInteger,cAsIntegerDimiAsIntege

當前文檔最多預覽五頁,下載文檔查看全文

此文檔下載收益歸作者所有

當前文檔最多預覽五頁,下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學公式或PPT動畫的文件,查看預覽時可能會顯示錯亂或異常,文件下載后無此問題,請放心下載。
2. 本文檔由用戶上傳,版權(quán)歸屬用戶,天天文庫負責整理代發(fā)布。如果您對本文檔版權(quán)有爭議請及時聯(lián)系客服。
3. 下載前請仔細閱讀文檔內(nèi)容,確認文檔內(nèi)容符合您的需求后進行下載,若出現(xiàn)內(nèi)容與標題不符可向本站投訴處理。
4. 下載文檔時可能由于網(wǎng)絡波動等原因無法下載或下載錯誤,付費完成后未能成功下載的用戶請聯(lián)系客服處理。