vb 生成20个1到100之间的随机数,统计其中的1位数,2位数,3位数的个数
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 19:39:26
privatesubcommand1_click()dima(1to10)asinteger,i,jfori=1to10a(i)=int(rnd*100)+1printa(i);nextprintfo
PrivateSubCommand1_Click()Dima(9)AsIntegerFori=0To9way1:Randomizea(i)=Int(Rnd()*10)+1Ifi>1ThenForp=0
窗体中加命令按钮,单击事件代码如下:PrivateSubCommand1_Click() Randomize Dima(1To20)AsInteger&nb
Private Sub Command1_Click()Text1.Text = ""Dim A(1 To 1
Dimb(100)PrivateSubCommand1_Click()Fori=1To100a=Int(1800*Rnd)+200b(i)=aPrintb(i)NextiEndSubb这个数组里面就保
OptionExplicitPrivatea(9)AsIntegerPrivateiMaxIndexAsIntegerPrivateSubCommand1_Click()Dimi,j,k,iMaxAs
dimiaslongdimsumaslongsum=0fori=1to100step2sum=sum+inextiprintsum
Toproducerandomintegersinagivenrange,usethisformula:Int((upperbound-lowerbound+1)*Rnd+lowerbound)Her
先在窗体上添加一个TextBox文本框(将其Multiline属性设置为True,并调整宽高以便能较好的显示出100个随机数)和一个Button按钮.然后双击Button按钮跳转到代码编辑窗口,粘帖以
1填写imod6=0,指的是余数要等于0;2填写S,表示要把S输出.
sub平方和()dimsumdimiaslongsum=0fori=1to100sum=sum+i*inextiendsu
Dima(1To3)AsStringFori=1To3Forj=1To3Randomizea(i)=a(i)&CStr(Int(Rnd*10))NextjNexti再问:不好意思,是我没有说清楚,我想
PrivateSubCommand1_Click()Dimoushu%,danshu%,sum%oushu=0danshu=0Fori=1To10Randomizesum=Int(Rnd*100)If
'声明变量dimMin_numasintdimMax_numasintdimSum_numasintdimArr_num(9)asint'赋予初始值Min_num=101Max_num=-1Sum_n
@arr = Array.newfor i in 0..19 do @arr << rand(1.
PrivateSubCommand1_Click()Fori=1To100IfiMod7=0Thenn=n+1EndIfNextiPrintnEndSu
前些天我才写的,是给别人弄的,他要的是1到100的十个数,并且按command2可以到换,我稍加修改给你(别忘了把窗体拉长点哈!短了后面不能显示哦)还要添加一个commandPrivateSubCom
PrivateSubCommand1_Click()RandomizeFori=1To20a=Int(Rnd()*21+30)Printa;IfiMod4=0ThenPrintNextEndSub这里
PrivateSubCommand1_Click()Dimoushu%,danshu%,sum%oushu=0danshu=0Fori=1To10Randomizesum=Int(Rnd*100)If
1)t=a(i)这句下标越界了,因为这时i=112)判断素数的语句也有点逻辑上的错误.3)随机数有可能重复.我改了下,请参考:PrivateSubForm_Click()Dima(1To10),iAs