欢迎来到天天文库
浏览记录
ID:48691804
大小:53.30 KB
页数:2页
时间:2020-02-27
《VB语言-2010春VB02上机答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、2010年(春)上机VisualBasic(VB02)答案一、改错【题目】本程序的功能是:利用随机函数生成n个可被3整除,且至少包含一个8的三位整数。OptionExplicitPrivateSubCommand1_Click()DimnAsInteger,a()AsInteger,iAsIntegerDimstAsStringn=InputBox("数据个数n:","查找",15)ReDima(n)Callfind(a)Fori=1TonIfiMod3<>0Then'errnMod3st=st&Str(a(i))Elsest=st&Str(a(i))&v
2、bCrLfEndIfNextiText1=stEndSubPrivateSubfind(a()AsInteger)DimubAsInteger,kAsInteger,pAsIntegerDimsAsStringRandomizeub=UBound(a)Dop=Int(Rnd*899)+100s=CStr(p)IfInStr(s,"8")<>0AndpMod3=0Then'errOrk=k+1a(k)=pEndIfLoopUntilk=ub'errk>ubEndSub二、编程题【题目】编写程序,求指定范围内的非素数整数的所有真因子(除1和自身以外的因子)。O
3、ptionExplicitPrivateSubCommand1_Click()DimxAsInteger,yAsInteger,a()AsIntegerDimnAsInteger,stAsString,jAsInteger,kAsIntegerx=Text1:y=Text2Forn=xToyk=0Callfa(n,a,k)st=n&":"Ifk<>0ThenForj=1ToUBound(a)st=st&a(j)&","NextjList1.AddItemLeft(st,Len(st)-1)ElseList1.AddItemstEndIfNextnEndSu
4、bPrivateSubfa(nAsInteger,a()AsInteger,kAsInteger)DimiAsIntegerFori=2Ton/2IfnModi=0Thenk=k+1ReDimPreservea(k)a(k)=iEndIfNextiEndSubPrivateSubCommand2_Click()Text1="":Text2=""List1.ClearText1.SetFocusEndSubPrivateSubCommand3_Click()EndEndSub
此文档下载收益归作者所有