I want to have a function
I have an array ar(300) as integer
There are different integers but also same integers in the ar
I wanted to know the sum of all integers who are different and how many there are who are different
Example
ar(1) = 1
ar(2) = 4
ar(3) = 4
ar(4) = 5
ar(5) = 6
ar(6) = 6
ar(7) = 8
ar(8) = 9
function(byref ar as integer, number as integer) as integer
array.sort(ar)
.....
end function
result
number = 4
function = 23
But, the function has to be very performant.
My question:
Can we get the result by running 1 time the ar.
for i = 1 to ar.getupperbound(0)
....
...
next
giving number and sum
Thanks for any response
I have an array ar(300) as integer
There are different integers but also same integers in the ar
I wanted to know the sum of all integers who are different and how many there are who are different
Example
ar(1) = 1
ar(2) = 4
ar(3) = 4
ar(4) = 5
ar(5) = 6
ar(6) = 6
ar(7) = 8
ar(8) = 9
function(byref ar as integer, number as integer) as integer
array.sort(ar)
.....
end function
result
number = 4
function = 23
But, the function has to be very performant.
My question:
Can we get the result by running 1 time the ar.
for i = 1 to ar.getupperbound(0)
....
...
next
giving number and sum
Thanks for any response