Two identical strings: Difference between revisions
Content added Content deleted
(Added solution for Action!) |
Not a robot (talk | contribs) (Add CLU) |
||
Line 1,262: | Line 1,262: | ||
990 1111011110 |
990 1111011110 |
||
</pre> |
</pre> |
||
=={{header|CLU}}== |
|||
<lang clu>nth_ident = proc (n: int) returns (int) |
|||
h: int := n |
|||
l: int := n |
|||
while l>0 do h, l := h*2, l/2 end |
|||
return(h + n) |
|||
end nth_ident |
|||
bits = proc (n: int) returns (string) |
|||
p: string := "" |
|||
if n>1 then p := bits(n/2) end |
|||
return(p || int$unparse(n//2)) |
|||
end bits |
|||
start_up = proc () |
|||
po: stream := stream$primary_output() |
|||
n: int := 0 |
|||
while true do |
|||
n := n+1 |
|||
ident: int := nth_ident(n) |
|||
if ident>=1000 then break end |
|||
stream$putright(po, int$unparse(ident), 3) |
|||
stream$putl(po, ": " || bits(ident)) |
|||
end |
|||
end start_up</lang> |
|||
{{out}} |
|||
<pre> 3: 11 |
|||
10: 1010 |
|||
15: 1111 |
|||
36: 100100 |
|||
45: 101101 |
|||
54: 110110 |
|||
63: 111111 |
|||
136: 10001000 |
|||
153: 10011001 |
|||
170: 10101010 |
|||
187: 10111011 |
|||
204: 11001100 |
|||
221: 11011101 |
|||
238: 11101110 |
|||
255: 11111111 |
|||
528: 1000010000 |
|||
561: 1000110001 |
|||
594: 1001010010 |
|||
627: 1001110011 |
|||
660: 1010010100 |
|||
693: 1010110101 |
|||
726: 1011010110 |
|||
759: 1011110111 |
|||
792: 1100011000 |
|||
825: 1100111001 |
|||
858: 1101011010 |
|||
891: 1101111011 |
|||
924: 1110011100 |
|||
957: 1110111101 |
|||
990: 1111011110</pre> |
|||
=={{header|COBOL}}== |
=={{header|COBOL}}== |
||
Line 1,360: | Line 1,417: | ||
957: 1110111101 |
957: 1110111101 |
||
990: 1111011110</pre> |
990: 1111011110</pre> |
||
=={{header|Cowgol}}== |
=={{header|Cowgol}}== |
||
<lang cowgol>include "cowgol.coh"; |
<lang cowgol>include "cowgol.coh"; |