Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,39 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
local fn BubbleSort( array as CFMutableArrayRef ) as CFArrayRef
|
||||
NSUInteger i, x, y, count = len(array)
|
||||
BOOL swapped = YES
|
||||
|
||||
while (swapped)
|
||||
swapped = NO
|
||||
for i = 1 to count -1
|
||||
x = fn NumberIntegerValue( array[i-1] )
|
||||
y = fn NumberIntegerValue( array[i] )
|
||||
if ( x > y )
|
||||
MutableArrayExchangeObjects( array, (i-1), i )
|
||||
swapped = YES
|
||||
end if
|
||||
next
|
||||
wend
|
||||
end fn = array
|
||||
|
||||
CFMutableArrayRef array
|
||||
CFArrayRef unsortedArray, sortedArray
|
||||
NSUInteger i
|
||||
|
||||
array = fn MutableArrayWithCapacity(0)
|
||||
for i = 0 to 20
|
||||
MutableArrayAddObject( array, fn NumberWithInteger( rnd(100) ) )
|
||||
next
|
||||
|
||||
unsortedArray = fn ArrayWithArray( array )
|
||||
sortedArray = fn BubbleSort( array )
|
||||
|
||||
NSLog( @"\n-----------------\nUnsorted : Sorted\n-----------------" )
|
||||
for i = 0 to 20
|
||||
NSLog( @"%8ld : %-8ld", fn NumberIntegerValue( unsortedArray[i] ), fn NumberIntegerValue( sortedArray[i] ) )
|
||||
next
|
||||
|
||||
randomize
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue