Two identical strings: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add COBOL) |
Not a robot (talk | contribs) (Add PL/I) |
||
Line 2,343: | Line 2,343: | ||
957: 1110111101 |
957: 1110111101 |
||
990: 1111011110</pre> |
990: 1111011110</pre> |
||
=={{header|PL/I}}== |
|||
<lang pli>identstr: procedure options(main); |
|||
bitLength: procedure(nn) returns(fixed); |
|||
declare (n, nn, r) fixed; |
|||
r = 0; |
|||
do n = nn repeat(n / 2) while(n > 0); |
|||
r = r + 1; |
|||
end; |
|||
return(r); |
|||
end bitLength; |
|||
concat: procedure(nn, m) returns(fixed); |
|||
declare (i, steps, nn, n, m) fixed; |
|||
steps = bitLength(m); |
|||
n = nn; |
|||
do i=1 to steps; |
|||
n = n * 2; |
|||
end; |
|||
return(n + m); |
|||
end concat; |
|||
printBits: procedure(nn); |
|||
declare (nn, n) fixed, bits char(16) varying; |
|||
bits = ''; |
|||
do n = nn repeat(n / 2) while(n > 0); |
|||
if mod(n,2) = 0 then |
|||
bits = '0' || bits; |
|||
else |
|||
bits = '1' || bits; |
|||
end; |
|||
put list(bits); |
|||
end printBits; |
|||
declare n fixed; |
|||
do n=1 repeat(n+1) while(concat(n,n) < 1000); |
|||
put skip list(concat(n,n)); |
|||
call printBits(concat(n,n)); |
|||
end; |
|||
end identstr;</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|PL/M}}== |
=={{header|PL/M}}== |