/// <Summary> /// whether the string exists in "any digit consisting of specified numbers in ascending order" /// eg: /// aset = 178 can be composed of any digit in ascending order: 1, 7, 8, 17, 18, 78, 178 // If Aval is one of them, true is returned, otherwise, false is returned /// </Summary> /// <Param name = "Aval"> value with judgment </param> /// <Param name = "aset"> ascending numeric string </param> function check_isallinascnumbersetbyanybit (const Aval, aset: string): Boolean; function combin (mstrings: tstrings; mstr: string; mlen: integer): Boolean; Procedure fcombin (msubstr: string; mpath: string); var I: integer; s: string; B: Boolean; lst: tstringlist; begin if length (mpath)> = mlen then begin lst: = tstringlist. create; for I: = 1 to length (mpath) Do begin lst. add (mpath [I]); end; lst. sort; B: = true; for I: = 0 to lst. count-1 do begin if lst [I] <> mpath [I + 1] Then begin B: = false; break; end; lst. free; if B then mstrings. add (mpath); End else for I: = 1 to length (msubstr) Do begin S: = msubstr; Delete (S, I, 1); fcombin (S, mpath + msubstr [I]); end; begin result: = false; if not assigned (mstrings) Then exit; mstrings. beginupdate; try mstrings. clear; fcombin (mstr, ''); finally mstrings. endupdate; end; Result: = true; end; var I: integer; lst: tstringlist; begin result: = false; lst: = tstringlist. create; try combin (LST, aset, length (Aval); for I: = 0 to lst. count-1 do begin if Aval = lst [I] Then begin result: = true; exit; end; finally lst. free; end; Procedure tform1.btn1click (Sender: tobject); begin if check_isallinascnumbersetbyanybit (edt1.text, '20140901') Then caption: = 'OK' else caption '; end;
Character arrangement and combination Delphi