VB编写随机产生一个数组,并且将数组元素逆序存放。(一维数组)
3个回答
展开全部
逆序:从大到小,还是,从小到大,还是什么?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command8_Click()
Dim b(0 To 10) As Integer, mp As Integer, i As Integer, x As Integer
Randomize
For i = 0 To 10
b(i) = Int(Rnd * (100 - 1 + 1) + 1)
Print b(i)
Next
Print
For i = 0 To UBound(b)
For x = i + 1 To UBound(b)
If b(x) > b(i) Then
mp = b(i)
b(i) = b(x)
b(x) = mp
End If
Next
Print b(i)
Next
End Sub
Dim b(0 To 10) As Integer, mp As Integer, i As Integer, x As Integer
Randomize
For i = 0 To 10
b(i) = Int(Rnd * (100 - 1 + 1) + 1)
Print b(i)
Next
For i = 0 To UBound(b)
For x = i + 1 To UBound(b)
If b(x) > b(i) Then
mp = b(i)
b(i) = b(x)
b(x) = mp
End If
Next
Print b(i)
Next
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a%(80)
Open "num1.txt" For Output As #1
Randomize
a(1) = Int(Rnd * 90 + 10)
k = 1
Do While k < 80
x = Int(Rnd * 90 + 10)
f = 0
For i = 1 To k
If x = a(i) Then
f = 1
Exit For
End If
Next i
If f = 0 Then
k = k + 1
a(k) = x
End If
Loop
n = 0
For i = 1 To 80
Write #1, a(i)
Text1.Text = Text1.Text & a(i) & " "
n = n + 1
Next i
Close #1
Private Sub Command2_Click()
Open "num1.txt" For Input As #1
k = 0
n = 0
For i = 1 To 80
Input #1,a( i)
For i = 1 To n - 1
For j = i + 1 To n
If a(i) >a(j) Then
t = a(i): a(i) = a(j): a(j) = t
End If
Next j
Next i
For j = 1 To n
Text2.Text = Text2.Text & a(j) & " "
k = k + 1
Next j
Close #1
End Sub
End Sub
Dim a%(80)
Open "num1.txt" For Output As #1
Randomize
a(1) = Int(Rnd * 90 + 10)
k = 1
Do While k < 80
x = Int(Rnd * 90 + 10)
f = 0
For i = 1 To k
If x = a(i) Then
f = 1
Exit For
End If
Next i
If f = 0 Then
k = k + 1
a(k) = x
End If
Loop
n = 0
For i = 1 To 80
Write #1, a(i)
Text1.Text = Text1.Text & a(i) & " "
n = n + 1
Next i
Close #1
Private Sub Command2_Click()
Open "num1.txt" For Input As #1
k = 0
n = 0
For i = 1 To 80
Input #1,a( i)
For i = 1 To n - 1
For j = i + 1 To n
If a(i) >a(j) Then
t = a(i): a(i) = a(j): a(j) = t
End If
Next j
Next i
For j = 1 To n
Text2.Text = Text2.Text & a(j) & " "
k = k + 1
Next j
Close #1
End Sub
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询