knrt.net
当前位置:首页 >> vB随机产生10个数 >>

vB随机产生10个数

Option Base 1 Dim i As Integer Dim j As Integer Dim a(10) As Integer Private Sub Command1_Click()'1、-----------------------------------'a(i) = Int(Rnd(1) * 100 + 1) '这里不对因为你使用了Option Base 1语句所以a()数组的最小下标是1,你这里i并没

Dim a(10) As Integer Dim s As StringPrivate Sub Command1_Click() Dim i, j, min, t As Integer For i = 1 To 9 min = i For j = i + 1 To 10 If a(j) < a(min) Then min = j Next j t = a(i) a(i) = a(min) a(min) = t Next i s = "" For i = 1 To 10 s = s & " " & a(i)

Private Sub Form_Click() Dim a(1 To 10) Randomize Timer For i = 1 To 10 a(i) = Int(Rnd * 90 + 10) Print a(i); " "; Next i For i = 1 To 9 For j = i + 1 To 10

Dim A(1 To 10) As Integer Private Sub 查找_Click() Dim N As Integer N = Val(Text1.Text) Dim sMin As Integer, sMax As Integer sMin = 1: sMax = 10 Do i = (sMin + sMax) / 2 If A(i) = N Then MsgBox N & "在数组中存在" Exit Sub ElseIf A(i) > N

Private Sub main() Dim i, j As IntegerDim min, temp As IntegerRandomize For i = 1 To 10 a(i) = 1 + Rnd * 10 print a(i); NextprintFor i = 1 To 9 min = a(i) For j = i + 1 To 10 If min > a(j) Then temp = a(j) a(j) = min min = temp End If Next a(i) = minNextfor i=1 to 10 print a(i)nextend sub

randomize for i=1 to 10 a=int(rnd*899)+100 print a next 欢迎追问,求采纳

'方法1,不是你的方法,呵呵,直接产生10个随机数记性排列,谁知道是怎么产生的 ,呵呵.randomizedim a(9)for i=0 to 9a(i)=int(rnd*300+101)next ifor j = 0 to 8 for k = 0 to 8 - j if a(k) > a(k + 1) then t = a(k) a(k) = a(k + 1) a(k + 1) = t end if next k

Dim arr(0 To 9) As Integer Private Sub Form_Load() Dim i, j, k Randomize For i = 0 To 9 arr(i) = Int(Rnd * 100) Debug.Print arr(i); Next i Debug.Print For i = 0 To 9 k = i For j = i + 1 To 9 If arr(k) > arr(j) Then k = j Next j If k <> i Then t = arr(k): arr(k) =

var str="" for i as integer =0 to 9 Randomize() Dim r As int= Cint(Rnd() * 1) str&=Cstr(r) next textbox1.text=str var sz=str.ToCharArray().Max() var wz=str.IndexOf(sz) MsgBox("最大数字" & sz & "在" & wz)

S=0S2=0FOR I=1 to 10 x=RND(0) S=S+x S2=S2+x*xNEXT IPRINT S2/10-(S/10)*(S/10)

网站首页 | 网站地图
All rights reserved Powered by www.knrt.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com