forked from Sbhinx/tryList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
64 lines (43 loc) · 1.06 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
#include <stdio.h>
#include <stdlib.h>
#include "SequenceList.h"
#include "linkedList.h"
//主程序
int main() {
/*
//初始化线性表
struct SequenceList list;
if (initSequenceList(&list)) {
for (int i = 1; i <= 20; ++i)
insertSequenceListElement(&list, i, i);
printSequenceListInfo(&list);
}
else {
printf("顺序表初始化失败,无法启动程序!");
}
//插入操作
insertSequenceListElement(&list, 12365464, 5);
printSequenceListInfo(&list);
//删除操作
deleteSequenceListElement(&list, -1);
printSequenceListInfo(&list);
*/
//初始化链表头节点
struct listNode head;
//初始化链表
initLinkedList(&head);
//插入操作
for (int i = 1; i <= 10; ++i) {
insertLinkedListElement(&head, i*100, i);
}
printLinkedListInfo(&head);
//删除操作
deleteLinkedListElement(&head, 5);
printLinkedListInfo(&head);
//访问元素
printf("访问的元素为:%d\n",*getLinkedListElement(&head, 5));
//查找某元素在该链表第一次出现的位置
E element = 200;
printf("'%d'在该链表第一次出现的位置在: %d\n", element,findLinkedListElement(&head, element));
return 1;
}