//15位转18位函数 function TForm1.ID15To18(OldID:string):string ; var i:Integer; num:Integer; code:string; strtemp:string; pvalue:string; begin num:=0; strtemp:=Leftstr(OldID,6)+ '19'+Rightstr(OldID,9); for i:=18 downto 2 do begin pvalue:=floattostr(power(2,i-1)); num:=num +(strtoint(pvalue) mod 11) * strtoint(Midstr(strtemp, 19 - i, 1)); end; num:=num mod 11; case num of 0: code:='1'; 1: code:='0'; 2: code:='X'; else code:=inttostr(12-num); end; Result:=strtemp+code; end;
function TForm1.ID15To18(OldID:string):string ;
var
i:Integer;
num:Integer;
code:string;
strtemp:string;
pvalue:string;
begin
num:=0;
strtemp:=Leftstr(OldID,6)+ '19'+Rightstr(OldID,9);
for i:=18 downto 2 do
begin
pvalue:=floattostr(power(2,i-1));
num:=num +(strtoint(pvalue) mod 11) * strtoint(Midstr(strtemp, 19 - i, 1));
end;
num:=num mod 11;
case num of
0: code:='1';
1: code:='0';
2: code:='X';
else
code:=inttostr(12-num);
end;
Result:=strtemp+code;
end;
中n是什么呀?怎么我计算出的Wi与原作者的值相差很远?