VB统计随机产生的数字中偶数个数
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/10 15:46:44
Dima%(1To20)Fori=1To20a(i)=Int(Rnd*90+10)Printa(i);NextPrintFori=1To20Ifa(i)Mod2=1ThenPrinta(i);EndI
PrivateSubForm_Load()Dima(10),i,x,jAsIntegerDimyAsStringFori=0To9Randomizea(i)=Int(Rnd(1)*101)x=x+a(
PrivateSubCommand1_Click()Dima(50),i,nRandomizeFori=1To50a(i)=Int(Rnd*191)+10Printa(i);IfiMod10=0The
PrivateSubCommand1_Click()Dima(10To99)AsIntegerFori=1To1000x=Int(90*Rnd())+10‘产生10~99的随机数a(x)=a(x)+1
PrivateSubCommand1_Click()Dima(10,6)AsString*2,b(30)AsIntegerDimmaxAsInteger,maxiAsInteger,maxjAsInt
先在窗体上添加一个TextBox文本框(将其Multiline属性设置为True,并调整宽高以便能较好的显示出100个随机数)和一个Button按钮.然后双击Button按钮跳转到代码编辑窗口,粘帖以
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccc
Dimm(99)AsInteger,n(9)AsInteger,iAsInteger,kAsIntegerRandomizeFori=0To99m(i)=Int(Rnd*100)Printm(i);k
Dimy%,x%Fori=1To10x=Int(Rnd*100)'[0,99]Printx;Ifi=1Theny=xElseIfy>xTheny=xEndIfNextiPrint"最小值";x如果是N
privatesubcommand1_click()dimjs,os,i,afori=1to20a=int(Rnd*99)+1ifamod2=0thenjs=js+ielseos=os+inextpr
'窗体放一个按钮Command1PrivateSubCommand1_Click()Randomize'初始化随机数生成器DimJiShuHangAsString'奇数行DimOuShuHangAsS
subform_click()dima%(20)fori=1to20a(i)=int(rnd()*10+1)printa(i),nextendsu
通过SubMain启动Submain()Dima(9)AsInteger,pAsDouble,iAsInteger,nAsIntegerp=0n=0Fori=0To9a(i)=Rnd*100p=p+a
添加两个控件名字分别为sc、tj的按钮.'定义一个窗体数组变量dima(10)asinteger'生成是个随机数privatesubsc_click()'下面这一句可以得到不同的随机数randomiz
PrivateSubCommand1_Click()c=InputBox("","","")Fora=1To100b=Int(Rnd*99)IfInt(Right(Str(b),1))=Int(c)T
PrivateSubCommand1_Click()DimArr(9)AsLong'用于存放产生的10随机数DimiAsLongDimnMaxAsLong'用于存放最大的偶数DimnMinAsLong
窗体上放个CommandButton和两个Label:PrivateSubCommand1_Click()DimiAsInteger,jAsInteger,nAsIntegerLabel1.Capti
PrivateSubForm_Click()Dima(30)AsIntegerDimiAsIntegerRandomizeFori=1To30a(i)=Int(100*Rnd)NextiFori=1T
vb6测试通过PrivateSubCommand1_Click()Dima(10)AsInteger,tempAsInteger,iAsInteger,jAsIntegerRandomizetemp=