急求!一道VB编程题 谢谢!
主调程序随机产生10个300到800之间的数,显示所产生的一维数组a中的各元素。编一子过程ProcMin(a(),amin),求数组a中的最小值amin。...
主调程序随机产生10个300到800之间的数,显示所产生的一维数组a中的各元素。编一子过程ProcMin(a(),amin),求数组a中的最小值amin。
展开
展开全部
Private Sub ProcMin(a() As Integer, ByVal amin As Integer)
Dim i%, amin0%
For i = LBound(a) To UBound(a)
Print a(i);
amin0 = a(LBound(a))
If a(i) < amin0 Then amin = a(i)
Next i
Print
Print "amin="; amin
End Sub
Private Sub Command1_Click()
Dim a(1 To 10) As Integer, i% ', amin0%
For i = 1 To 10
a(i) = Int(501 * Rnd + 300)
Next i
Call ProcMin(a(), amin)
End Sub
Dim i%, amin0%
For i = LBound(a) To UBound(a)
Print a(i);
amin0 = a(LBound(a))
If a(i) < amin0 Then amin = a(i)
Next i
Print "amin="; amin
End Sub
Private Sub Command1_Click()
Dim a(1 To 10) As Integer, i% ', amin0%
For i = 1 To 10
a(i) = Int(501 * Rnd + 300)
Next i
Call ProcMin(a(), amin)
End Sub
展开全部
主程序
Dim a(10) As Integer
Randomize
For i = 0 To 9
a(i) = Int((800 - 300 + 1) * Rnd + 300)
Next
ProcMin(a())
--子函数
Function ProcMin(a() As Integer) As Integer
Dim min As Integer
min = a(0)
For i = 1 To 9
If min > a(i) Then
min = a(i)
End If
Next
ProcMin = min
End Function
Dim a(10) As Integer
Randomize
For i = 0 To 9
a(i) = Int((800 - 300 + 1) * Rnd + 300)
Next
ProcMin(a())
--子函数
Function ProcMin(a() As Integer) As Integer
Dim min As Integer
min = a(0)
For i = 1 To 9
If min > a(i) Then
min = a(i)
End If
Next
ProcMin = min
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
他们编的都很好!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询