身份证号码15到18位升位算法Delphi实现
2000年写的一个函数,大家用得上的话可以看看:
function GetNewID(ID: string): string;
const
 W: array[1..18] of Integer = (7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1);
 A: array[0..10] of Char = ('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
var
 i, j, S: integer;
 NewID: string;
begin
 if Length(ID) <> 15 then
   result := ''
 else
 begin
   NewID := ID;
   Insert('19', NewID, 7);
   S := 0;
   try
     for i := 1 to 17 do
     begin
       j := StrToInt(NewID[i]) * W[i];
       S := S + j;
     end;
   except
     result := '';
     exit;
   end;
   S := S mod 11;
   Result := NewID + A[S];
 end;
end;
 

  • 相关文章

    • 无相关文章
Last modification:February 16, 2010
稀罕你