35 lines
816 B
Plaintext
35 lines
816 B
Plaintext
DIM bucket(10)
|
|
FOR i = 1 TO 10 : bucket(i) = int(RND(0)*100) : NEXT
|
|
|
|
a = display(" Display:") ' show original array
|
|
a = flatten(a) ' flatten the array
|
|
a = display(" Flatten:") ' show flattened array
|
|
a = transfer(3,5) ' transfer some amount from 3 to 5
|
|
a = display(a;" from 3 to 5:") ' Show transfer array
|
|
end
|
|
|
|
FUNCTION display(a$)
|
|
print a$;" ";chr$(9);
|
|
for i = 1 to 10
|
|
display = display + bucket(i)
|
|
print bucket(i);chr$(9);
|
|
next i
|
|
print " Total:";display
|
|
END FUNCTION
|
|
|
|
FUNCTION flatten(f)
|
|
f1 = int((f / 10) + .5)
|
|
for i = 1 to 10
|
|
bucket(i) = f1
|
|
f2 = f2 + f1
|
|
next i
|
|
bucket(10) = bucket(10) + f - f2
|
|
END FUNCTION
|
|
|
|
|
|
FUNCTION transfer(a1,a2)
|
|
transfer = int(rnd(0) * bucket(a1))
|
|
bucket(a1) = bucket(a1) - transfer
|
|
bucket(a2) = bucket(a2) + transfer
|
|
END FUNCTION
|