16,748
社区成员
发帖
与我相关
我的任务
分享
function IntTo34(Value: Integer;Digits: Integer): string;
const
Key: array[0..33] of char=('0','1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
var
FTmp,FTmp1:Integer;
begin
FTmp:=Value;
while FTmp>0 do
begin
FTmp1:=FTmp mod 34;
Result:=Key[FTmp1]+Result;
FTmp:=(FTmp-FTmp1) div 34;
end;
FTmp:=Digits-Length(Result);
if FTmp>0 then
Result:=StringOfChar('0',FTmp)+Result;
end;
function DecTo34(iDec, iDigit: Integer): String;
const
C : array[0..33] of Char = (
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
begin
Result := '';
while iDec >= 34 do
begin
Result := C[iDec mod 34] + Result;
iDec := iDec div 34;
end;
Result := C[iDec] + Result;
Result := StringOfChar('0', iDigit - Length(Result)) + Result;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
begin
for i := 1 to 50 do
Memo1.Lines.Add('KFP81204OM-' + DecTo34(i, 4));
end;