Data update
This commit is contained in:
parent
61b93a2cd1
commit
5af6d93694
858 changed files with 20572 additions and 2082 deletions
50
Task/Atomic-updates/FutureBasic/atomic-updates.basic
Normal file
50
Task/Atomic-updates/FutureBasic/atomic-updates.basic
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
local fn PopulateArrayWithRandomNumbers
|
||||
NSUInteger i
|
||||
|
||||
for i = 0 to 9
|
||||
mda (i) = rnd(90)
|
||||
next
|
||||
end fn
|
||||
|
||||
local fn Display( title as CFStringRef ) as NSUInteger
|
||||
NSUInteger i, worth = 0
|
||||
CFStringRef comma = @","
|
||||
|
||||
printf @"%@ [\b", title
|
||||
for i = 0 to 9
|
||||
worth += mda_integer (i)
|
||||
if i == 9 then comma = @""
|
||||
printf @"%2lu%@\b", mda_integer (i), comma
|
||||
next
|
||||
printf @"] Sum = %lu", worth
|
||||
end fn = worth
|
||||
|
||||
local fn Flatten( f as NSUInteger )
|
||||
NSUInteger i, f1 = int((f / 10) + .5 ), f2 = 0, temp
|
||||
|
||||
for i = 0 to 9
|
||||
mda (i) = f1
|
||||
f2 += f1
|
||||
next
|
||||
temp = mda_integer (9)
|
||||
mda (9) = temp + f - f2
|
||||
end fn
|
||||
|
||||
local fn Transfer( a1 as NSUInteger, a2 as NSUInteger )
|
||||
NSUInteger t, temp = int( rnd( mda_integer ( a1 ) ) )
|
||||
|
||||
t = mda_integer ( a1 ) : mda ( a1 ) = t -temp
|
||||
t = mda_integer ( a2 ) : mda ( a2 ) = t +temp
|
||||
end fn
|
||||
|
||||
NSUInteger a, i
|
||||
|
||||
random
|
||||
fn PopulateArrayWithRandomNumbers
|
||||
a = fn Display( @" Initial array:" )
|
||||
fn Flatten( a )
|
||||
a = fn Display( @" Current values:" )
|
||||
fn Transfer( 3, 5 )
|
||||
fn Display( @" 19 from 3 to 5:" )
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue