-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteste-linkedList.c
59 lines (48 loc) · 1.36 KB
/
teste-linkedList.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
#include "common/common.h"
#include "structs/header/linkedList.h"
int main(int argc, char *argv[]){
int n, size;
LinkedListInt l = newLinkedListInt();
LinkedListIntNode node = NULL;
size = 1;
size = randIntB2in(1, 5);
printf("Incerindo %d valores:\n", size);
for(int i = 0; i < size; i++){
n = randInt(100);
print(n);
print(", ");
insetBackLinkedListInt(l, n);
}
printNewLine();
size = randIntB2in(1, 5);
printf("Incerindo %d valores no inicio:\n", size);
for(int i = 0; i < size; i++){
n = randInt(100);
print(n);
print(", ");
insetFrontLinkedListInt(l, n);
}
printNewLine();
printf("Lista resultante com %d valores:\n", l->size);
for(int i = 0; i < l->size; i++){
n = getLinkedListIntValue(l, i);
printf("l[%d] = %d, ", i, n);
}
printNewLine();
readF(&n, "Remover valor: ");
node = searchValueLinkedListInt(l, n);
if(node != NULL){
removeLinkedListNode(l, node);
printf("Lista resultante com %d valores:\n", l->size);
for(int i = 0; i < l->size; i++){
n = getLinkedListIntValue(l, i);
printf("l[%d] = %d, ", i, n);
}
printNewLine();
}
else{
printLn("O valor não está na lista");
}
deleteLinkedListInt(l);
return 0;
}