VB题目,求解答~~ 20
2.求数组最大最小元素位置运行程序;按“运行”按钮,则生成随机数组并显示在图片框Pic1中,并在图片框Pic2中输出数组最大元素值和最小元素值及相应的数组元素的行号与列号...
2.求数组最大最小元素位置 运行程序;按“运行”按钮,则生成随机数组并显示在图片框Pic1中,并在图片框Pic2中输出数组最大元素值和最小元素值及相应的数组元素的行号与列号(如35 3 4);按“清除”按钮,将两个图片框清空;单击“结束”按钮,结束程序运行;程序中应定义一个通用过程用于求二维数组最大元素与最小元素值。
展开
1个回答
展开全部
VB编写一个找出一维数组的最大元素与最小元素的通用过程,并调用此过程,找出由10个两位随机正整数组成的数组的最大元素和最小元素的程序。
以下是我做的,请问怎么修改?
Private Sub maxmin(a() As ingeter)
Dim i As Integer
Max = : Min = ————————不知道填什么……
For i = LBound(a) + 1 To UBound(a)
If a(i) > Max Then
Max = a(i)
ElseIf a(i) < Min Then
Min = a(i)
End If
Next i
End Sub
Private Sub Command1_Click()
Dim x(10) As Integer, maxv As Integer, minv As Integer
Dim i As Integer
For i = 1 To 10
x(i) = maxv
Text1 = Text1 & Str(x(i))
Next i
Call maxmin(x())
Text1 = maxv
Text2 = minv
End Sub
Private Sub Command2_Click()
Text1.Text = "": Text2.Text = ""
End Sub
Private Sub Command3_Click()
End
End Sub
以下是我做的,请问怎么修改?
Private Sub maxmin(a() As ingeter)
Dim i As Integer
Max = : Min = ————————不知道填什么……
For i = LBound(a) + 1 To UBound(a)
If a(i) > Max Then
Max = a(i)
ElseIf a(i) < Min Then
Min = a(i)
End If
Next i
End Sub
Private Sub Command1_Click()
Dim x(10) As Integer, maxv As Integer, minv As Integer
Dim i As Integer
For i = 1 To 10
x(i) = maxv
Text1 = Text1 & Str(x(i))
Next i
Call maxmin(x())
Text1 = maxv
Text2 = minv
End Sub
Private Sub Command2_Click()
Text1.Text = "": Text2.Text = ""
End Sub
Private Sub Command3_Click()
End
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询