-
Notifications
You must be signed in to change notification settings - Fork 0
/
5-15-10-31-20.52.c
91 lines (85 loc) · 2.52 KB
/
5-15-10-31-20.52.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* 5-15-10-31-20.52.c -- 第五章第十一题 */
#include <stdio.h>
#include "extendible_hashing.h"
int main (void) ;
void print_subdirectories (const Subdirectories subdirectories) ;
int main (void)
{
Table t ;
Item item ;
InitializeTable (&t) ;
item = 32 ;
Insert (&t, &item) ;
item = 33 ;
Insert (&t, &item) ;
item = 34 ;
Insert (&t, &item) ;
item = 35 ;
Insert (&t, &item) ;
putchar ('\n') ;
item = 64 ;
Insert (&t, &item) ;
item = 65 ;
Insert (&t, &item) ;
item = 66 ;
Insert (&t, &item) ;
item = 80 ;
Insert (&t, &item) ;
putchar ('\n') ;
item = 68 ;
Insert (&t, &item) ;
printf ("【【%d】】\n", Insert (&t, &item)) ;
item = 32 ;
Delete (&t, &item) ;
item = 99 ;
Insert (&t, &item) ;
item = 107 ;
Insert (&t, &item) ;
item = 96 ;
Insert (&t, &item) ;
item = 126 ;
Insert (&t, &item) ;
item = 127 ;
if (Delete (&t, &item))
{
printf ("%d\n", t -> directory[0].point -> array[0]) ;
printf ("%d\n", t -> directory[0].point -> array[1]) ;
printf ("%d\n", t -> directory[0].point -> array[2]) ;
printf ("%d\n", t -> directory[0].point -> array[3]) ;
printf ("%d\n", t -> directory[1].point -> array[0]) ;
printf ("%d\n", t -> directory[1].point -> array[1]) ;
printf ("%d\n", t -> directory[1].point -> array[2]) ;
printf ("%d\n", t -> directory[1].point -> array[3]) ;
printf ("%d\n", t -> directory[2].point -> array[0]) ;
printf ("%d\n", t -> directory[2].point -> array[1]) ;
printf ("%d\n", t -> directory[2].point -> array[2]) ;
printf ("%d\n", t -> directory[2].point -> array[3]) ;
printf ("%d\n", t -> directory[3].point -> array[0]) ;
printf ("%d\n", t -> directory[3].point -> array[1]) ;
printf ("%d\n", t -> directory[3].point -> array[2]) ;
printf ("%d\n", t -> directory[3].point -> array[3]) ;
printf ("%d\n", t -> directory[4].point -> array[0]) ;
printf ("%d\n", t -> directory[4].point -> array[1]) ;
printf ("%d\n", t -> directory[4].point -> array[2]) ;
printf ("%d\n", t -> directory[4].point -> array[3]) ;
printf ("%d\n", t -> directory[5].point -> array[0]) ;
printf ("%d\n", t -> directory[5].point -> array[1]) ;
printf ("%d\n", t -> directory[5].point -> array[2]) ;
printf ("%d\n", t -> directory[5].point -> sub) ;
}
printf ("%d\n", Find (&t, &item)) ;
putchar ('\n') ;
Traversal (&t, print_subdirectories) ;
Release (&t) ;
return 0 ;
}
void print_subdirectories (const Subdirectories subdirectories)
{
int count ;
count = subdirectories.point -> sub - 1 ;
while (count >= 0)
{
printf ("%d\n", subdirectories.point -> array[count]) ;
count-- ;
}
}