This repository has been archived by the owner on Mar 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
125 lines (107 loc) · 3.58 KB
/
main.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "test/test-arrayList.h"
#include "structure/arrayList.h"
#include "structure/linkList.h"
#include "./functions/polyCalculation.h"
#include "functions/expressionCalculation.h"
#include "functions/matrixCalculation.h"
#include "structure/orthogonalList.h"
#include "functions/hashTableOperation.h"
#include "test/test-linkList.h"
#include "test/test-binaryTree.h"
#include "test/test-treeCalculator.h"
int operationArrayList();
int operationLinkList();
int operationStack();
int linkList_compare(LinkListValue value1, LinkListValue value2);
int main(){
//arrayListTest();
//polyCalculation();
//operationStack();
//operationArrayList();
//operationLinkList();
//linkListTest();
//expCalculation();
//hashTableCalculation();
//binaryTreeTest();
treeCalculatorTest();
//matrixCalculation();
//system("pause");
return 0;
}
int linkList_compare(LinkListValue value1, LinkListValue value2){
if (value1 == value2){
return 0;
}else if (value1 > value2) return 1;
else if (value1 < value2) return -1;
}
int operationStack(){
LinkListEntry* linkList = linkList_initList();
linkList_pop(linkList);
linkList_pop(linkList);
linkList_pop(linkList);
linkList_push(linkList, 2);
linkList_push(linkList, 5);
linkList_push(linkList, 6);
linkList_push(linkList, 2);
linkList_show(linkList);
linkList_pop(linkList);
linkList_show(linkList);
printf("The top value of the stack is : %d\n", linkList_peek(linkList));;
linkList_show(linkList);
printf("The length of the stack is : %d\n",linkList_getLength(linkList));
linkList_destroy(linkList);
}
int operationLinkList(){
LinkListEntry* linkList = linkList_initList();
linkList_appendNode(linkList, 1);
linkList_appendNode(linkList, 2);
linkList_appendNode(linkList, 5);
linkList_appendNode(linkList, 6);
linkList_appendNode(linkList, 2);
linkList_prependNode(linkList, 1231321);
linkList_show(linkList);
linkList_deleteNode(linkList,linkList_getIndexEntryByIndex(linkList,0));
linkList_show(linkList);
linkList_getIndexEntryByData(linkList, 2 ,linkList_compare);
printf("升序排列的结果为: ");
linkList_sort(linkList,0,linkList_compare);
linkList_show(linkList);
printf("降序排列的结果为: ");
linkList_sort(linkList,1,linkList_compare);
linkList_show(linkList);
printf("The length of the linkList is : %d\n",linkList_getLength(linkList));
linkList_destroy(linkList);
}
int operationArrayList() {
ArrayList *arrayList;
arrayList = arrayList_init();
int entries[] = { 89, 4, 23, 42, 4, 16, 15, 4, 8, 99, 50, 30, 4 };
for (int i = 0 ;i<13;i++){
arrayList_append(arrayList,entries[i]);
}
/*
arrayList_append(arrayList,1);
arrayList_append(arrayList,5);
arrayList_append(arrayList,2);
arrayList_append(arrayList,7);
arrayList_append(arrayList,3);*/
arrayList_show(arrayList);
printf("数组长度为:%d \n",arrayList_getLength(arrayList));
//arrayList_insert(arrayList,2,201);
// arrayList_show(arrayList);
// arrayList_remove(arrayList,4);
// arrayList_show(arrayList);
printf("升序排列的结果为:\n");
arrayList_sort(arrayList, 0);
arrayList_show(arrayList);
printf("降序排列的结果为:\n");
arrayList_sort(arrayList, 1);
arrayList_show(arrayList);
printf("201 的数组索引为:%d \n",arrayList_getIndexByValue(arrayList,201));
printf("数组索引为1的值为:%d \n",(int)arrayList_getValueByIndex(arrayList,1));
arrayList_destroy(arrayList);
return 0;
}