如何对比动态数组中的每个数组大小
展开全部
用排序就好了, 分别取出首尾6个元素
dim arr()
'''''''
redim arr(5)
arr(0) = 100
arr(1) = 435
arr(2) = 800
arr(3) = 220
arr(4) = 50
arr(5) = 999
Dim x, y, b, tmp
for y = 0 to ubound(arr)
b = true
for x = 0 to ubound(arr) - 1
if arr(x) > arr(x+1) then
tmp = arr(x)
arr(x) = arr(x+1)
arr(x+1) = tmp
b = false
end if
next
if b then exit for
next
dim content
for each x in arr
content = content & x & chr(13)
next
content = content & "min-" & arr(0) & " - " & arr(1) & " - " & arr(2) & chr(13)
content = content & "max-" & arr(ubound(arr)) & " - "
& arr(ubound(arr) - 1) & " - " & arr(ubound(arr) - 2) &
chr(13)
msgbox content
dim arr()
'''''''
redim arr(5)
arr(0) = 100
arr(1) = 435
arr(2) = 800
arr(3) = 220
arr(4) = 50
arr(5) = 999
Dim x, y, b, tmp
for y = 0 to ubound(arr)
b = true
for x = 0 to ubound(arr) - 1
if arr(x) > arr(x+1) then
tmp = arr(x)
arr(x) = arr(x+1)
arr(x+1) = tmp
b = false
end if
next
if b then exit for
next
dim content
for each x in arr
content = content & x & chr(13)
next
content = content & "min-" & arr(0) & " - " & arr(1) & " - " & arr(2) & chr(13)
content = content & "max-" & arr(ubound(arr)) & " - "
& arr(ubound(arr) - 1) & " - " & arr(ubound(arr) - 2) &
chr(13)
msgbox content
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |