Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
45
Task/Align-columns/FutureBasic/align-columns.basic
Normal file
45
Task/Align-columns/FutureBasic/align-columns.basic
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
local fn AlignColumn
|
||||
NSUInteger i
|
||||
|
||||
CFStringRef testStr = @"Given$a$text$file$of$many$lines,$where$fields$within$a$line$are$delineated$by¬
|
||||
$a$single$'dollar'$character,$write$a$program$that$aligns$each$column$of$fields$by$ensuring$that$words¬
|
||||
$in$each$column$are$separated$by$at$least$one$space.$Further,$allow$for$each$word$in$a$column$to$be¬
|
||||
$either$left$justified$right$justified,$or$center$justified$within$its$column."
|
||||
|
||||
CFArrayRef temp = fn StringComponentsSeparatedByString( testStr, @"$" )
|
||||
CFMutableArrayRef arr = fn MutableArrayWithArray( temp )
|
||||
NSUInteger count = fn ArrayCount( arr )
|
||||
ptr a(50)
|
||||
|
||||
NSLog( @"\nLeft aligned:\n" )
|
||||
NSUInteger lineCheck = 1
|
||||
for i = 0 to count -1
|
||||
a( lineCheck ) = (ptr)fn StringUTF8String( arr[i] )
|
||||
if ( lineCheck == 9 )
|
||||
NSLog( @"%-12s %-11s %-12s %-11s %-12s %-12s %-12s %-12s %-12s", a(1),a(2),a(3),a(4),a(5),a(6),a(7),a(8),a(9) )
|
||||
lineCheck = 1
|
||||
else
|
||||
lineCheck++
|
||||
end if
|
||||
next
|
||||
|
||||
NSLog( @"\n\nRight aligned:\n" )
|
||||
|
||||
lineCheck = 1
|
||||
for i = 0 to count -1
|
||||
a( lineCheck ) = (ptr)fn StringUTF8String( arr[i] )
|
||||
if ( lineCheck == 9 )
|
||||
NSLog( @"%12s %11s %12s %11s %12s %12s %12s %12s %12s", a(1),a(2),a(3),a(4),a(5),a(6),a(7),a(8),a(9) )
|
||||
lineCheck = 1
|
||||
else
|
||||
lineCheck++
|
||||
end if
|
||||
next
|
||||
|
||||
end fn
|
||||
|
||||
fn AlignColumn
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue