-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdll-1-5.c
34 lines (32 loc) · 815 Bytes
/
dll-1-5.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
#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(1006);
DLL *p = newDLL(displayREAL,freeREAL);
int i;
for (i = 0; i < 18; ++i)
{
int j = random() % 100;
int k = random() % (sizeDLL(p) + 1);
j += (random() % 100) / 100.0;
insertDLL(p,k,newREAL(j));
}
if (sizeDLL(p) < 100)
{
displayDLL(p,stdout);
printf("\n");
}
printf("size is %d\n",sizeDLL(p));
printf("value at 3 is %.2lf\n",getREAL(getDLL(p,3)));
printf("setting value at 3 to 85.68\n");
freeREAL(setDLL(p,3,newREAL(85.68)));
printf("value at 3 now is %.2lf\n",getREAL(getDLL(p,3)));
freeDLL(p);
return 0;
}