Home > Software engineering >  Could you tell me who can help the VB code son transfer into Python, variable name don't change
Could you tell me who can help the VB code son transfer into Python, variable name don't change

Time:11-08

Function Hash (Key) As an Integer
Dim Address As Integer
Dim x, y, num1, num2, num3, num4, total As Integer
Dim a, b As Char
Dim c As String

X=Asc (a)

B=Mid (Key, 2, 1)
Y=Asc (b)

C=Right (Key, 4)

Num1=CInt (Left (c, 1))
Num2=CInt (Mid (c, 2, 1))
Num3=CInt (Mid (c, 3, 1))
Num4=CInt (c, 1) (Right)

Total=x + y + num1 + num2 + num3 + num4
Address=total Mod 6

The Return Address

Dim HashTable (5) As String
Sub Main ()
Dim Key As String
Dim Index As an Integer
Dim Max=5
For I=1 To 5
Console. WriteLine (" Enter CustomerID. ")
Key=Console. ReadLine
The Index=Hash (Key)
While HashTable (Index) & lt;> Nothing
The Index=Index + 1
If the Index & gt; Max Then
The Index=1
End the If
End While
HashTable (Index)=Key
Next
For I=1 To 5
Console. WriteLine (HashTable (I))
Next
End Sub

The Function SearchHashTable (SearchID) As an Integer
The Index=Hash (SearchID)
While HashTable (Index) & lt;> SearchID And HashTable (Index)=Nothing
The Index=Index + 1
If the Index & gt; 5 Then
The Index=0
End the If
End While
If HashTable (Index)=SearchID Then
Console. WriteLine (" ID Found. ")
Return Index
The Else
Console. WriteLine (" ID not found. ")
The Return - 1
End the If
End the Function


As Integer Function OutputLetter (B)
Then the If x=Len (B)
End
The Else
X=x + 1
Console. WriteLine (Mid (B, x, 1))
OutputLetter (B)
End the If
Return the x
End the Function

CodePudding user response:

This is a hash search code, you first turn a roughly, a line or two can not help you
  • Related