:[0,23|[0,59|[0,59|~b+c+d=a|?!b$+@:`+right$(@0`+!c$,2)+A+right$(B+!d$,2)
这在QBasic中很不幸,因为将其转换为数字,修剪和0
在必要时添加前缀确实非常昂贵。
样本输出:
Command line: 119
1:59:59
2:58:59
2:59:58
3:57:59
[... SNIP 270 lines ...]
23:58:38
23:59:37
解释我写了一本关于它的小说:
: Get N, call it 'a'
[0,23| Loop through the hours; this FOR loop is initialised with 2 parameters
using a comma to separate FROM and TO, and a '|' to delimit the argument list
[0,59| Same for the minutes
[0,59| And the seconds
QBIC automatically creates variables to use as loop-counters:
b, c, d (a was already taken by ':')
~b+c+d=a IF a == b+c+d
| THEN
? PRINT
! CAST
b 'b'
$ To String; casting num to str in QBasic adds a space, this is trimmed in QBIC
+@:` Create string A$, containing ":"
+right$ This is a QBasic function, but since it's all lowercase (and '$' is
not a function in QBIC) it remains unaltered in the resulting QBasic.
(@0`+!c$,2) Pad the minutes by prepending a 0, then taking the rightmost 2 characters.
+A Remember that semicolon in A$? Add it again
+right$ Same for the seconds
(B+!d$,2) Reusing the 0-string saves 2 bytes :-)