1个回答
展开全部
Sub maxmin(a, n, max, min)
max = Val(a(1)): min = Val(a(1))
For i = 2 To n
If max < Val(a(i)) Then max = Val(a(i))
If min > Val(a(i)) Then min = Val(a(i))
Next i
End Sub
Sub printit(a)
For i = 1 To UBound(a)
Print Right(" " & a(i), 5);
Next i
Print
End Sub
Private Sub Command1_Click()
a = Split(",1,12,3", ",")
b = Split(",1,2,3,14,5", ",")
c = Split(",1,2,3,34,5,6,7", ",")
printit a
maxmin a, 3, max, min
Print "最大值:" & max
Print "最小值:" & min & vbCrLf & vbCrLf
printit b
maxmin b, 5, max, min
Print "最大值:" & max
Print "最小值:" & min & vbCrLf & vbCrLf
printit c
maxmin c, 7, max, min
Print "最大值:" & max
Print "最小值:" & min & vbCrLf & vbCrLf
End Sub
max = Val(a(1)): min = Val(a(1))
For i = 2 To n
If max < Val(a(i)) Then max = Val(a(i))
If min > Val(a(i)) Then min = Val(a(i))
Next i
End Sub
Sub printit(a)
For i = 1 To UBound(a)
Print Right(" " & a(i), 5);
Next i
End Sub
Private Sub Command1_Click()
a = Split(",1,12,3", ",")
b = Split(",1,2,3,14,5", ",")
c = Split(",1,2,3,34,5,6,7", ",")
printit a
maxmin a, 3, max, min
Print "最大值:" & max
Print "最小值:" & min & vbCrLf & vbCrLf
printit b
maxmin b, 5, max, min
Print "最大值:" & max
Print "最小值:" & min & vbCrLf & vbCrLf
printit c
maxmin c, 7, max, min
Print "最大值:" & max
Print "最小值:" & min & vbCrLf & vbCrLf
End Sub
追问
好高手
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询