📄 gint.pas
字号:
If x[6] = '0' Then g := 31 Else g := 32;
End
End
End
End
End
Else
Begin
If x[2] = '0' Then
Begin
If x[3] = '0' Then
Begin
If x[4] = '0' Then
Begin
If x[5] = '0' Then
Begin
If x[6] = '0' Then g := 33 Else g := 34;
End
Else
Begin
If x[6] = '0' Then g := 35 Else g := 36;
End
End
Else
Begin
If x[5] = '0' Then
Begin
If x[6] = '0' Then g := 37 Else g := 38;
End
Else
Begin
If x[6] = '0' Then g := 39 Else g := 40;
End
End
End
Else
Begin
If x[4] = '0' Then
Begin
If x[5] = '0' Then
Begin
If x[6] = '0' Then g := 41 Else g := 42;
End
Else
Begin
If x[6] = '0' Then g := 43 Else g := 44;
End
End
Else
Begin
If x[5] = '0' Then
Begin
If x[6] = '0' Then g := 45 Else g := 46;
End
Else
Begin
If x[6] = '0' Then g := 47 Else g := 48;
End
End
End
End
Else
Begin
If x[3] = '0' Then
Begin
If x[4] = '0' Then
Begin
If x[5] = '0' Then
Begin
If x[6] = '0' Then g := 49 Else g := 50;
End
Else
Begin
If x[6] = '0' Then g := 51 Else g := 52;
End
End
Else
Begin
If x[5] = '0' Then
Begin
If x[6] = '0' Then g := 53 Else g := 54;
End
Else
Begin
If x[6] = '0' Then g := 55 Else g := 56;
End
End
End
Else
Begin
If x[4] = '0' Then
Begin
If x[5] = '0' Then
Begin
If x[6] = '0' Then g := 57 Else g := 58;
End
Else
Begin
If x[6] = '0' Then g := 59 Else g := 60;
End
End
Else
Begin
If x[5] = '0' Then
Begin
If x[6] = '0' Then g := 61 Else g := 62;
End
Else
Begin
If x[6] = '0' Then g := 63 Else g := 64;
End
End
End
End
End
End;
Procedure initialize8(Var trans : Array Of String);
Var
c1, c2, c3, c4, c5, c6, c7, c8 : integer;
x : String;
g : char;
Begin
For c1 := 0 To 1 Do
For c2 := 0 To 1 Do
For c3 := 0 To 1 Do
For c4 := 0 To 1 Do
For c5 := 0 To 1 Do
For c6 := 0 To 1 Do
For c7 := 0 To 1 Do
For c8 := 0 To 1 Do
Begin
x := '';
x := inttostr(c1) + inttostr(c2) + inttostr(c3) + inttostr(c4) + inttostr(c5) + inttostr(c6) + inttostr(c7) + inttostr(c8);
zeronetochar8(g, x);
trans[ord(g)] := x;
End;
End;
Procedure initialize6(Var trans : Array Of String);
Var
c1, c2, c3, c4, c5, c6 : integer;
x : String;
g : integer;
Begin
For c1 := 0 To 1 Do
For c2 := 0 To 1 Do
For c3 := 0 To 1 Do
For c4 := 0 To 1 Do
For c5 := 0 To 1 Do
For c6 := 0 To 1 Do
Begin
x := '';
x := inttostr(c1) + inttostr(c2) + inttostr(c3) + inttostr(c4) + inttostr(c5) + inttostr(c6);
zeronetochar6(g, x);
trans[ord(chr64[g])] := x;
End;
End;
// Convert 8 bit strings to 6 bit strings and visa versa
Procedure Convert8to6bit(str8 : String; Var str6 : String);
Var
temp : String;
trans : Array[0..255] Of String;
i, len6 : longint;
g : integer;
Begin
initialize8(trans);
temp := '';
For i := 1 To length(str8) Do temp := temp + trans[ord(str8[i])];
While (length(temp) Mod 6) <> 0 Do temp := temp + '0';
len6 := length(temp) Div 6;
str6 := '';
For i := 1 To len6 Do
Begin
zeronetochar6(g, copy(temp, 1, 6));
str6 := str6 + chr64[g];
delete(temp, 1, 6);
End;
End;
Procedure Convert6to8bit(str6 : String; Var str8 : String);
Var
temp : String;
trans : Array[0..255] Of String;
i, len8 : longint;
g : char;
Begin
initialize6(trans);
temp := '';
For i := 1 To length(str6) Do temp := temp + trans[ord(str6[i])];
str8 := '';
len8 := length(temp) Div 8;
For i := 1 To len8 Do
Begin
zeronetochar8(g, copy(temp, 1, 8));
str8 := str8 + g;
delete(temp, 1, 8);
End;
End;
// Convert 8 & 6 bit strings to 1 bit strings and visa versa
Procedure Convert8to1bit(str8 : String; Var str1 : String);
Var
trans : Array[0..255] Of String;
i : longint;
Begin
str1 := '';
initialize8(trans);
For i := 1 To length(str8) Do str1 := str1 + trans[ord(str8[i])];
End;
Procedure Convert6to1bit(str6 : String; Var str1 : String);
Var
trans : Array[0..255] Of String;
i : longint;
Begin
str1 := '';
initialize6(trans);
For i := 1 To length(str6) Do str1 := str1 + trans[ord(str6[i])];
End;
Procedure Convert1to8bit(str1 : String; Var str8 : String);
Var
i, len8 : longint;
g : char;
Begin
str8 := '';
While (length(str1) Mod 8) <> 0 Do str1 := '0' + str1;
len8 := length(str1) Div 8;
For i := 1 To len8 Do
Begin
zeronetochar8(g, copy(str1, 1, 8));
str8 := str8 + g;
delete(str1, 1, 8);
End;
End;
Procedure Convert1to6bit(str1 : String; Var str6 : String);
Var
i, len6 : longint;
g : integer;
Begin
str6 := '';
While (length(str1) Mod 6) <> 0 Do str1 := '0' + str1;
len6 := length(str1) Div 6;
For i := 1 To len6 Do
Begin
zeronetochar6(g, copy(str1, 1, 6));
str6 := str6 + chr64[g];
delete(str1, 1, 6);
End;
End;
// convert a base 10 string to a GInt and visa versa
Procedure DecStrToGInt(GIntstr : String; Var GInt : TGInt);
Var
temp1, temp2 : TGInt;
p : Tsign;
Begin
While Not (GIntstr[1] In ['-', '0'..'9']) Do delete(GIntstr, 1, 1);
If GIntstr[1] = '-' Then
Begin
delete(GIntstr, 1, 1);
p := negative;
End
Else p := positive;
While (GIntstr[1] = '0') And (length(GIntstr) > 1) Do delete(GIntstr, 1, 1);
new(temp2);
temp2^.next := Nil;
If (length(GIntstr) Mod 4) = 0 Then
Begin
temp2^.value := strtoint(copy(GIntstr, 1, 4));
delete(GIntstr, 1, 4);
End
Else
Begin
temp2^.value := strtoint(copy(GIntstr, 1, (length(GIntstr) Mod 4)));
delete(GIntstr, 1, (length(GIntstr) Mod 4));
End;
While length(GIntstr) > 0 Do
Begin
new(temp1);
temp1^.next := temp2;
temp2^.prev := temp1;
temp1^.value := strtoint(copy(GIntstr, 1, 4));
delete(GIntstr, 1, 4);
temp2 := temp1;
End;
temp2^.prev := Nil;
temp2^.sign := p;
GInt := temp2;
End;
Procedure GIntToDecStr(Var GIntstr : String; GInt : TGInt);
Var
s : String;
p : TSign;
Begin
GIntstr := '';
p := GInt^.sign;
s := inttostr(GInt^.value);
While length(s) < 4 Do s := '0' + s;
GIntstr := s + GIntstr;
While GInt^.next <> Nil Do
Begin
GInt := GInt^.next;
s := inttostr(abs(GInt^.value));
While length(s) < 4 Do s := '0' + s;
GIntstr := s + GIntstr;
End;
While (GIntstr[1] = '0') And (length(GIntstr) > 1) Do delete(GIntstr, 1, 1);
If p = negative Then GIntstr := '-' + GIntstr;
End;
// Convert an integer to a GInt
Procedure IntToGInt(Int : integer; Var GInt : TGInt);
Begin
DecstrtoGInt(inttostr(Int), GInt);
End;
// Destroy a GInt, in order to free memory
Procedure GIntDestroy(Var GInt : TGInt);
Begin
While GInt^.next <> Nil Do GInt := GInt^.next;
While GInt^.prev <> Nil Do
Begin
GInt := GInt^.prev;
dispose(GInt^.next);
End;
dispose(GInt);
End;
// Make a copy of a GInt
Procedure GIntCopy(GInt1 : TGInt; Var GInt2 : TGInt);
Var
temp1, temp2 : TGInt;
Begin
new(GInt2);
GInt2^.sign := GInt1^.sign;
GInt2^.prev := Nil;
GInt2^.value := GInt1^.value;
temp1 := GInt2;
While GInt1^.next <> Nil Do
Begin
GInt1 := GInt1^.next;
new(temp2);
temp2^.value := GInt1^.value;
temp2^.prev := temp1;
temp1^.next := temp2;
temp1 := temp2;
End;
temp1^.next := Nil;
End;
// Divide a GInt by an integer, GInt = res * by + m
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -