欢迎来到天天文库
浏览记录
ID:39150551
大小:82.00 KB
页数:24页
时间:2019-06-25
《VB常用算法代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实用标准文档Feb数列前18项OptionBase1PrivateSubForm_Click()DimFeb(18)AsInteger,IAsIntegerFeb(1)=1Feb(2)=1ForI=3To18Feb(I)=Feb(I-1)+Feb(I-2)NextForI=1To18PrintFeb(I),IfIMod5=0ThenPrintNextEndSub鞍点OptionExplicitOptionBase1PrivateSubForm_Click()ClsDimA(4,5)AsInteger,IAsInteger,JAsInteger,KAsIntegerDimMaxAsI
2、nteger,MinAsIntegerDimRowAsInteger,ColAsInteger,FlagAsBooleanRandomizeForI=1To4ForJ=1To5A(I,J)=Rnd*90+10PrintA(I,J);NextPrintNextI=1Flag=FalseDoWhileI<=4Max=A(I,1)Row=ICol=1ForJ=2To5IfMaxA(K,Col)ThenI=I+1Flag=FalseExitForE
3、ndIfNextIfK=5ThenFlag=TrueExitDoEndIfLoopIfNotFlagThenPrint"鞍点不存在!"ElsePrint"鞍点的位置:"&CStr(Row)&"行"&CStr(Col)&"列"EndSub插入排序OptionBase1PrivateSubCommand1_Click()DimA(10)AsInteger,IAsInteger,JAsInteger,XAsIntegerClsPrint"排序前:";ForI=1To10A(I)=Int(100*Rnd)PrintA(I);NextPrintForJ=2To10X=A(J)I=J-1DoW
4、hileX5、Integer,MiddleAsIntegerDimKAsIntegerForJ=2To10X=A(J)First=1Last=J-1DoWhileFirst<=LastMiddle=(First+Last)/2IfX>A(Middle)ThenLast=Middle-1ElseFirst=Middle+1EndIfLoopForK=J-1ToMiddleStep-1A(K+1)=A(K)NextA(Middle)=XNextPrint"排序后:";ForI=1To10PrintA(I);NextEndSub插入一个数到有序数列DimA(10)AsInteger,IAsIntege6、r,JAsIntegerPrivateSubCommand1_Click()DimXAsInteger文案大全实用标准文档X=Text1.TextI=9DoWhileXA(J)Thentemp=A(I)A(I)=A(J)A7、(J)=tempEndIfNextNextPrint"有序序列:";ForI=0To9PrintA(I);NextPrintText1.SetFocusEndSubPrivateSubForm_Activate()Print"将一个数插入到一个有序的序列中!"EndSub查找子串位置OptionBase1文案大全实用标准文档PrivateSubCommand1_Click()DimS1AsString,S2AsStringS1=Text1.TextS2=Text2.T
5、Integer,MiddleAsIntegerDimKAsIntegerForJ=2To10X=A(J)First=1Last=J-1DoWhileFirst<=LastMiddle=(First+Last)/2IfX>A(Middle)ThenLast=Middle-1ElseFirst=Middle+1EndIfLoopForK=J-1ToMiddleStep-1A(K+1)=A(K)NextA(Middle)=XNextPrint"排序后:";ForI=1To10PrintA(I);NextEndSub插入一个数到有序数列DimA(10)AsInteger,IAsIntege
6、r,JAsIntegerPrivateSubCommand1_Click()DimXAsInteger文案大全实用标准文档X=Text1.TextI=9DoWhileXA(J)Thentemp=A(I)A(I)=A(J)A
7、(J)=tempEndIfNextNextPrint"有序序列:";ForI=0To9PrintA(I);NextPrintText1.SetFocusEndSubPrivateSubForm_Activate()Print"将一个数插入到一个有序的序列中!"EndSub查找子串位置OptionBase1文案大全实用标准文档PrivateSubCommand1_Click()DimS1AsString,S2AsStringS1=Text1.TextS2=Text2.T
此文档下载收益归作者所有