37 lines
762 B
Plaintext
37 lines
762 B
Plaintext
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);
|
|
]
|