-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdll-1-1.c
44 lines (42 loc) · 993 Bytes
/
dll-1-1.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 "real.h"
extern void srandom(unsigned int);
extern long int random(void);
int
main(void)
{
srandom(1002);
DLL *p = newDLL(displayREAL,freeREAL);
insertDLL(p,0,newREAL(3.3));
insertDLL(p,sizeDLL(p),newREAL(2.2));
displayDLL(p,stdout);
printf("\n");
freeREAL(removeDLL(p,1));
displayDLL(p,stdout);
printf("\n");
freeREAL(removeDLL(p,0));
displayDLL(p,stdout);
printf("\n");
DLL *q = newDLL(displayREAL,freeREAL);
insertDLL(p,0,newREAL(6.7));
insertDLL(p,0,newREAL(8.9));
insertDLL(q,0,newREAL(4.3));
insertDLL(q,0,newREAL(5.2));
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;
}