Two identical strings: Difference between revisions

Added solution for Action!
m (→‎{{header|ALGOL W}}: Add syntax highlighting)
(Added solution for Action!)
Line 273:
957 1110111101
990 1111011110</pre>
 
=={{header|Action!}}==
<lang Action!>INT FUNC Encode(INT x CHAR ARRAY s)
BYTE len,i
CHAR tmp
 
len=0 tmp=x
WHILE tmp#0
DO
len==+1
s(len)='0+(tmp&1)
tmp==RSH 1
OD
FOR i=1 TO len RSH 1
DO
tmp=s(i) s(i)=s(len-i+1) s(len-i+1)=tmp
OD
FOR i=1 TO len
DO
s(i+len)=s(i)
OD
s(0)=len
RETURN (x LSH len+x)
 
PROC Main()
CHAR ARRAY s(20)
INT i=[1],res,count=[0]
 
DO
res=Encode(i,s)
IF res>=1000 THEN
EXIT
FI
Position((count&1)*15+2,count RSH 1+1)
PrintF("%I: %S",res,s)
i==+1 count==+1
OD
RETURN</lang>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Two_identical_strings.png Screenshot from Atari 8-bit computer]
<pre>
3: 1 10: 10
15: 11 36: 100
45: 101 54: 110
63: 111 136: 1000
153: 1001 170: 1010
187: 1011 204: 1100
221: 1101 238: 1110
255: 1111 528: 10000
561: 10001 594: 10010
627: 10011 660: 10100
693: 10101 726: 10110
759: 10111 792: 11000
825: 11001 858: 11010
891: 11011 924: 11100
957: 11101 990: 11110
</pre>
 
=={{header|Ada}}==
Anonymous user