QBIC , 82 72 바이트
:[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 :-)