function CompStr(ps1,ps2
Char):Boolean;var iCount:Integer;begin result:=False
iCount:=abs(strlen(ps1)-strlen(ps2))
if iCount>2 then exit
while (ps1^<>#0) and (ps2^<>#0) do begin if ps1^<>ps2^ then inc(iCount)
inc(ps1)
inc(ps2)
end
result:=iCount=2;end;procedure TForm1.Button1Click(Sender: TObject);var i,j,iCount:Integer
s1,s2:string
used:array of Integer;begin iCount:=ListBox1.Count-1
if iCount<=0 then exit
Memo1.Clear
SetLength(used,iCount+1)
try for i:=0 to iCount do begin s1:=ListBox1.Items
if used=1 then Continue
for j:=1 to iCount do begin if used[j]=1 then Continue
s2:=ListBox1.Items[j]
if CompStr(PChar(s1),PChar(s2)) then begin Memo1.Lines.Add('***********************************')
Memo1.Lines.Add(s1)
Memo1.Lines.Add(s2)
Memo1.Lines.Add('***********************************')
Memo1.Lines.Add('')
used[j]:=1
end
end
end
finally used:=nil
end;end;