-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change for loop run time change test add time module
- Loading branch information
Showing
4 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,9 @@ | |
``` | ||
Reverse(s : STRING) RETURNS STRING | ||
``` | ||
## [Time](./time.cpc) | ||
* Time 获取当前时间戳 | ||
``` | ||
Time RETURNS REAL | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FUNCTION Time RETURNS REAL | ||
RETURN PYTHON("from time import time; _result=time()") | ||
ENDFUNCTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
DECLARE a : INTEGER | ||
OUTPUT a | ||
DELETE a | ||
DECLARE t1 : REAL | ||
DECLARE t2 : REAL | ||
|
||
FUNCTION aux(n:INTEGER, acc1:INTEGER, acc2:INTEGER) RETURNS INTEGER | ||
IF n = 1 THEN RETURN acc1 ENDIF | ||
IF n = 2 THEN RETURN acc2 ENDIF | ||
RETURN aux(n - 1, acc2, acc1 + acc2) | ||
ENDFUNCTION | ||
|
||
t1 <- PYTHON("from time import time; _result=time()") | ||
OUTPUT "aux: " | ||
OUTPUT aux(46, 0, 1) | ||
OUTPUT PYTHON("from time import time; _result=time()") - t1 | ||
|
||
|
||
FUNCTION fib(i:INTEGER) RETURNS INTEGER | ||
IF i = 1 THEN RETURN 1 ENDIF | ||
IF i = 2 THEN RETURN 1 ENDIF | ||
RETURN fib(i - 1) + fib(i - 2) | ||
ENDFUNCTION | ||
|
||
t2 <- PYTHON("from time import time; _result=time()") | ||
OUTPUT "fib: " | ||
OUTPUT fib(46) | ||
OUTPUT PYTHON("from time import time; _result=time()") - t2 |