Longest common substring: Difference between revisions

Added XPL0 example.
(Added XPL0 example.)
Line 2,750:
</pre>
 
=={{header|XPL0}}==
{{trans|C}}
<syntaxhighlight lang "XPL0">string 0;
 
proc LCS(SA, SB, Beg, End);
char SA, SB;
int Beg, End;
int APos, BPos, Len;
[Beg(0):= 0; End(0):= 0; Len:= 0;
APos:= 0;
while SA(APos) # 0 do
[BPos:= 0;
while SB(BPos) # 0 do
[if SA(APos) = SB(BPos) then
[Len:= 1;
while SA(APos+Len) # 0 and SB(BPos+Len) # 0 and
SA(APos+Len) = SB(BPos+Len) do Len:= Len+1;
];
if Len > End(0) - Beg(0) then
[Beg(0):= SA + APos;
End(0):= Beg(0) + Len;
Len:= 0;
];
BPos:= BPos+1;
];
APos:= APos+1;
];
];
 
char S1, S2, It;
int Beg, End;
[S1:= "thisisatest";
S2:= "testing123testing";
LCS(S1, S2, @Beg, @End);
for It:= Beg to End-1 do
ChOut(0, It(0));
CrLf(0);
]</syntaxhighlight>
{{out}}
<pre>
test
</pre>
 
=={{header|Yabasic}}==
Line 2,765 ⟶ 2,807:
print LCS$("thisisatest", "testing123testing")
end</syntaxhighlight>
 
 
=={{header|zkl}}==
295

edits