wyl458619358 2021-04-19 10:41 采纳率: 0%
浏览 18

Oracle 33进制如何转换为10进制

想要写一个function,将输入的33进制字符串输出为10进制。

33进制字符串'0123456789ACDEFGHJKLMNPQRSTUVWXYZ'

 

  • 写回答

2条回答 默认 最新

  • 张开双翼 2021-04-19 11:52
    关注

    unit Unit1;

     

    interface

     

    uses

      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

      Dialogs, StdCtrls;

     

    type

      TForm1 = class()

        Edit1: TEdit;

        Edit2: TEdit;

        Button1: TButton;

        Button2: TButton;

        Button3: TButton;

        Label1: TLabel;

        Label2: TLabel;

        procedure Button1Click(Sender: TObject);

        procedure Button2Click(Sender: TObject);

        procedure Button3Click(Sender: TObject);

      private

        { Private declarations }

      public

        { Public declarations }

      end;

     

    var

      Form1: TForm1;

     

    implementation

     

    {$R *.dfm}

     

    const

    // ACIIS表 由字符对应数字

      Convert: array[0..255of Integer =

       (-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        33123456789,-1,-1,-1,-1,-1,-1,

        -1,10,11,12,13,14,15,16,17,-1,18,19,20,21,22,-1,

        23,24,25,26,27,-1,28,29,30,31,32,-1,-1,-1,-1,-1,

        -1,10,11,12,13,14,15,16,17,-1,18,19,20,21,22,-1,

        23,24,25,26,27,-1,28,29,30,31,32,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1);

    // 数字(下标)对应字符

      Convert2: array[0..33of AnsiChar =

       '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','V','W','X',

         'Y','Z','0');

     

    function IntToHEX33(const V: Int64const Digits: Integer = -1):string;

    const CSTR = '0000000000000000';

    var P, P1: PAnsiChar;

        I: Int64;

        NewLen: Integer;

    begin

      GetMem(P, 16);

      Move(CSTR, P^, 16);

      P1 := P + 16 1;

      I := V;

      while True do

      begin

        P1^ := Convert2[I mod 33];

        I := I div 33;

        if I = 0

          then Break

          else Dec(P1);

      end;

      NewLen := 16 - (P1 - P);

      if NewLen > Digits

        then SetString(Result, P1, NewLen)

        else begin

          P1 := P + 16 - Digits;

          SetString(Result, P1, Digits);

        end;

    end;

     

    function HEX33ToInt(const S: stringconst Default: Int64): Int64;

    var I: Integer;

        v: Int64;

    begin

      Result := 0;

      for I := 1 to length(s) do

      begin

        V := Convert[ord(s[i])];

        if V < 0 then

        begin

          Result := Default;

          Exit;

        end;

        result := (result * 33) + V;

      end;

    end;

     

    procedure TForm1.Button1Click(Sender: TObject);

    begin

      Edit2.Text := IntToHEX33(StrToInt64Def(Edit1.Text, 0));

    end;

     

    procedure TForm1.Button2Click(Sender: TObject);

    begin

      Edit1.Text := IntToStr(HEX33ToInt(Edit2.Text, 0));

    end;

     

    procedure TForm1.Button3Click(Sender: TObject);

    begin

      close;

    end;

     

    end.

    评论

报告相同问题?

悬赏问题

  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗