Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
45
Task/Middle-three-digits/Action-/middle-three-digits.action
Normal file
45
Task/Middle-three-digits/Action-/middle-three-digits.action
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
INCLUDE "H6:REALMATH.ACT"
|
||||
INCLUDE "D2:PRINTF.ACT" ;from the Action! Tool Kit
|
||||
|
||||
PROC MiddleThreeDigits(REAL POINTER n CHAR ARRAY res)
|
||||
REAL r
|
||||
CHAR ARRAY s(15)
|
||||
BYTE i
|
||||
|
||||
RealAbs(n,r)
|
||||
StrR(r,s)
|
||||
i=s(0)
|
||||
IF i<3 OR (i&1)=0 THEN
|
||||
res(0)=0
|
||||
ELSE
|
||||
i==RSH 1
|
||||
SCopyS(res,s,i,i+2)
|
||||
FI
|
||||
RETURN
|
||||
|
||||
PROC Test(CHAR ARRAY s)
|
||||
REAL n
|
||||
CHAR ARRAY res(4)
|
||||
|
||||
ValR(s,n)
|
||||
MiddleThreeDigits(n,res)
|
||||
IF res(0) THEN
|
||||
PrintF("%9S -> %S%E",s,res)
|
||||
ELSE
|
||||
PrintF("%9S -> error!%E",s)
|
||||
FI
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
Put(125) PutE() ;clear the screen
|
||||
|
||||
Test("123") Test("12345")
|
||||
Test("1234567") Test("987654321")
|
||||
Test("10001") Test("-10001")
|
||||
Test("-123") Test("-100")
|
||||
Test("100") Test("-12345")
|
||||
Test("1") Test("2")
|
||||
Test("-1") Test("-10")
|
||||
Test("2002") Test("-2002")
|
||||
Test("0")
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue