-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdll-1-2.c
44 lines (42 loc) · 1019 Bytes
/
dll-1-2.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
#include <stdio.h>
#include <stdlib.h>
#include "dll.h"
#include "string.h"
extern void srandom(unsigned int);
extern long int random(void);
int
main(void)
{
srandom(1003);
DLL *p = newDLL(displaySTRING,freeSTRING);
insertDLL(p,0,newSTRING("a"));
insertDLL(p,sizeDLL(p),newSTRING("b"));
displayDLL(p,stdout);
printf("\n");
freeSTRING(removeDLL(p,1));
displayDLL(p,stdout);
printf("\n");
freeSTRING(removeDLL(p,0));
displayDLL(p,stdout);
printf("\n");
DLL *q = newDLL(displaySTRING,freeSTRING);
insertDLL(p,0,newSTRING("e"));
insertDLL(p,0,newSTRING("f"));
insertDLL(q,0,newSTRING("c"));
insertDLL(q,0,newSTRING("d"));
displayDLL(p,stdout);
printf("\n");
displayDLL(q,stdout);
printf("\n");
unionDLL(p,q);
displayDLL(p,stdout);
displayDLL(q,stdout);
printf("\n");
displayDLLdebug(p,stdout);
printf("\n");
displayDLLdebug(q,stdout);
printf("\n");
freeDLL(p);
freeDLL(q);
return 0;
}