随机产生整数VB
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/20 04:54:51
![随机产生整数VB](/uploads/image/f/7722417-57-7.jpg?t=%E9%9A%8F%E6%9C%BA%E4%BA%A7%E7%94%9F%E6%95%B4%E6%95%B0VB)
Private Sub Command1_Click()Text1.Text = ""Dim A(1 To 1
DimnMaxasInteger,nMinasInteger,nTmpasInteger,nJsqasIntegerDimdSumasDoubleRandomizenTmp=CInt(Rnd*100)
PrivateSubCommand1_Click()Dima(50),i,nRandomizeFori=1To50a(i)=Int(Rnd*191)+10Printa(i);IfiMod10=0The
RANDOM(1,30)
改用通用的获取随机字符的方式.定义一个字符串strAph="abcd.ABCD..."取随机一个字符a=mid(strAph,int(rnd(52))+1)
Dima(9)AsIntegerRandomizea(0)=Int(Rnd()*21+10)Doa(1)=Int(Rnd()*21+10)LoopWhilea(1)=a(0)Doa(2)=Int(Rn
我已经上机验证过了,正确.思路:产生80个随机数,把这80个随机数由小到大排序,然后从第1个到第80个的顺序挑选偶数,赋值给字符串s1,够10个换行.再从第80个到第1个的顺序挑选奇数,赋值给字符串s
LS的回答有可能出来100(三位数)改为a=int(Rnd*100)b=int(Rnd*100)
PrivateSubCommand1_Click()DimiAsInteger,nAsInteger,mAsIntegerFori=1To50n=Int(1+Rnd*100)IfnPrintn;m=m
Dimy%,x%Fori=1To10x=Int(Rnd*100)'[0,99]Printx;Ifi=1Theny=xElseIfy>xTheny=xEndIfNextiPrint"最小值";x如果是N
再问:谢了,能否把程序给提供一下,我不会再答:好吧!
functionsj(i%,a%,b%)aslongDimx%x=Int(Rnd*(b-a+1))+asj=xEndfunctionPrivateSubCommand1_Click()Dimn%,a%
是的!
dima(30)fori=1to30a(i)=int(rnd(97+3))ifisprime(a(i))=truethenprinta(i);nextifunctionisprime(xasinteg
Dima(10)AsIntegerDimi%,j%,t%RandomizFori=1To10a(i)=Int(Rnd*90+10)Printa(i);NextPrintFori=1To9Forj=i+
[0,4)[0,10)再问:第二个怎么能是[0,10]再答:Rand(2)是[0,2)然后再乘以5就是[0,10)包括0,但不包括10再问:Int(Rnd(1)*4+1)这样应该是[1,4]了吧?再答
PrivateSubCommand1_Click()DimArr(9)AsLong'用于存放产生的10随机数DimiAsLongDimnMaxAsLong'用于存放最大的偶数DimnMinAsLong
DimMyValue(10)AsIntegerDimi,j,pAsIntegerFori=0To9RandomizeMyValue(i)=Int((100*Rnd)+1)NextFori=0To9Fo
PrivateSubCommand1_Click()DimZs(1To35)AsIntegerFori=1To35RandomizeZs(i)=Int(61*Rnd)+20PrintZs(i);Nex
Randomizea=int(rnd*6)+50