vb.net - Function to order numbers; find common difference and gap -
i have vb6 function take 7 numbers, order them, find common difference. there gap in sequence of numbers. want identify missing number.
example input 19,17,20,and 16
. output should array 16,17,18,19,20
in order. help? may able interpret vb.net code vb6, vb6 preferred me.
here’s outline of needs done:
- find smallest , largest number
- create array enough entries hold full range smallest largest
- fill array numbers lowest highest.
note don’t need sort numbers @ all. need find extreme values.
here’s code outline in vb6:
function rangefrom(paramarray numbers() long) long() dim lowest long dim highest long lowest = numbers(0) highest = numbers(0) dim number long each number in numbers if number < lowest lowest = number if number > highest highest = number next dim result(0 highest - lowest) long dim long = 0 highest - lowest result(i) = lowest + next fromrange = result end function
Comments
Post a Comment