李一航:提供个数组重复过滤算法

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/08 08:15:23

function removeDuplication(byref sourceArray()) as variant()
..dim returns()
..dim uboundReturns as integer:uboundReturns = -1
..dim i as integer, j as integer
..for i=0 to ubound(sourceArray)
....dim found as boolean:found=false
....for j=0 to uboundReturns - 1
......if (sourceArray(i) = returns(j)) then found = true
....next
....if (not found) then
......uboundReturns = uboundReturns + 1
......redim preserve returns(uboundReturns)
......returns(uboundReturns) = sourceArray(i)
....endif
..next
..
..removeDuplication = returns
end function