home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Go64!
/
Go64_2000-07_2000_CSW_Side_B.d64
/
hashing(deutsch)
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
1KB
|
52 lines
1 m=29:rem liste fuer 197 eintraege
2 gosub 10
3 goto 300
10 rem - hashfunktion definieren -
11 rem - und tabelle initialisieren -
12 def fn modm(n)=n-int(n/m)*m
13 def fn h(k)=fn modm(fn modm(k)+i)
14 dim t(m): rem arrays
15 dim a$(m):rem dimensionieren
16 for j=0 to m:t(j)=-1:next:rem loeschen
17 return
30 rem ---- hash insert ----
40 i=0
50 j=fn h(k)
60 if t(j)<0 then t(j)=k:return
70 i=i+1:if i < m goto 50
80 print "?hash table overflow error":stop
90 j=-1:return
100 rem ---- hash search ----
110 i=0
120 j=fn h(k)
130 if t(j)=k then return
140 i=i+1
150 if (t(j)=-1) or (i=m) then j=-1:return
160 goto 120
170 rem ---- hash delete ----
180 gosub 110:if j=-1 then return
190 t(j)=-2:return
300 print "[147]1.neuer eintrag"
310 print "2.suchen"
320 print "3.loeschen"
330 get x$:if x$="" then goto 330
340 if x$="1" then gosub 1000
350 if x$="2" then gosub 2000
360 if x$="3" then gosub 3000
370 goto 300
1000 input "name";n$
1010 input "telefonnummer";k
1020 gosub 30
1030 if j=-1 then print "liste voll!"
1040 if j>=0 then print "listenposition:";j
1050 a$(j)=n$:poke198,0:wait198,1:return
2000 input "telefonnummer";k
2010 gosub 100
2020 if j=-1 then print"nicht gefunden!":goto2050
2030 print "listenposition:";j
2040 print "name:";a$(j)
2050 poke198,0:wait198,1:return
3000 input "telefonnummer";k
3010 gosub 170:print"eintrag geloescht"
3020 poke198,0:wait198,1:return