L
liuyang
Unregistered / Unconfirmed
GUEST, unregistred user!
function dwdmjym(dwdm:string;var ReChar:Char):Boolean;<br>const<br> Wi: array[1..8] of string = ('3','7','9','10','5','8','4','2');<br> ai: array[0..35] of string = ('0','1','2','3','4','5','6','7','8','9','A',<br> 'B','C','D','E','F','G','H','I','J','K','L',<br> 'M','N','O','P','Q','R','S','T','U','V','W',<br> 'X','Y','Z');<br> bi: array[0..35] of string = ('0','1','2','3','4','5','6','7','8','9','10',<br> '11','12','13','14','15','16','17','18','19','20','21',<br> '22','23','24','25','26','27','28','29','30','31','32',<br> '33','34','35');<br> function GetAi(S:Char):string;<br> var I:integer;<br> begin<br> Result :='';<br> for I:=0 to 35 do<br> if S=ai then<br> begin<br> Result :=bi;<br> Break;<br> end;<br> end;<br>var<br> J,Sum,ModResult:integer;<br> S:string;<br>begin<br> Result:=True;<br> Sum:=0;<br> for J:=1 to Length(dwdm) do<br> begin<br> S:=GetAi(dwdm[J]);<br> if S='' then<br> begin<br> Result :=False;<br> Break;<br> end;<br> Sum:=Sum+strtoint(S)*strtoint(Wi[J]);<br> end;<br> if not Result then Exit;<br> ModResult:=Sum mod 11;<br> if ModResult=1 then ReChar:='X'<br> else if ModResult=0 then ReChar:='0'<br> else begin<br> S :=inttostr(11-ModResult);<br> ReChar:=S[1];<br> end;<br>end;<br><br>function dwdmjy(dwdm:string):Boolean;<br>var ReChar:Char;<br>begin<br> Result :=dwdmjym(Copy(dwdm,1,8),ReChar);<br> if Result then<br> if ReChar<>dwdm[9] then Result :=False;<br>end;