diff --git a/Project2/Debug/Project2.log b/Project2/Debug/Project2.log index 10bca46..8bbefbd 100644 --- a/Project2/Debug/Project2.log +++ b/Project2/Debug/Project2.log @@ -1,3 +1,4 @@ - sq_list.c -C:\code\lencode\Project2\sq_list.c(10,1): warning C4716: “init_sq_list”: 必须返回一个值 + linked_list.c +C:\code\lencode\Project2\linked_list.c(31,24): warning C4028: 形参 1 与声明不同 +C:\code\lencode\Project2\linked_list.c(59,2): warning C4047: “return”:“address_node *”与“int”的间接级别不同 Project2.vcxproj -> C:\code\lencode\Project2\Debug\Project2.exe diff --git a/Project2/Debug/Project2.tlog/CL.command.1.tlog b/Project2/Debug/Project2.tlog/CL.command.1.tlog index 9ca4aac..cc68b3c 100644 Binary files a/Project2/Debug/Project2.tlog/CL.command.1.tlog and b/Project2/Debug/Project2.tlog/CL.command.1.tlog differ diff --git a/Project2/Debug/Project2.tlog/CL.read.1.tlog b/Project2/Debug/Project2.tlog/CL.read.1.tlog index d321be2..ab688c7 100644 Binary files a/Project2/Debug/Project2.tlog/CL.read.1.tlog and b/Project2/Debug/Project2.tlog/CL.read.1.tlog differ diff --git a/Project2/Debug/Project2.tlog/CL.write.1.tlog b/Project2/Debug/Project2.tlog/CL.write.1.tlog index d4dd94b..026ce36 100644 Binary files a/Project2/Debug/Project2.tlog/CL.write.1.tlog and b/Project2/Debug/Project2.tlog/CL.write.1.tlog differ diff --git a/linked_list.c b/linked_list.c index ddd4769..d2774ea 100644 --- a/linked_list.c +++ b/linked_list.c @@ -24,5 +24,47 @@ void delete_node(node* n) // 滻ڵֵ void replace_node(node* n, int val) { - + n->value = val; } + +// ڵ +void insert_node(node* head, int val) +{ + node* new_node = init_node(val); + new_node->next = head->next->next; + head->next = new_node; +} + +// ʽڵ + +int get_node(node* n) +{ + return n->value; +} + +// +address_node *find_node(node* head, int val) +{ + address_node* n = (address_node*)malloc(sizeof(address_node)); + n->n = 0; + n->p = head; + while(1) + { + if (head->value == val) + return n; + n->n += 1; + head = head->next; + } + printf("޷ҵڵ\n"); + return -1; +} + +// ӡ +void print_node_list(node* head) +{ + while (head->next != NULL) + { + head = head->next; + printf("%d ", head->value); + } +} \ No newline at end of file diff --git a/linked_list.h b/linked_list.h index c170697..984b3c7 100644 --- a/linked_list.h +++ b/linked_list.h @@ -7,6 +7,13 @@ typedef struct node struct node* next; } node; +typedef struct address_node +{ + int n; + node* p; +}address_node; + + // ʼڵ node* init_node(int val); @@ -23,9 +30,10 @@ void insert_node(node** head, int val); int get_node(node* n); // -int find_node(node* head, int val); - +address_node *find_node(node* head, int val); +// ӡ +void print_node_list(node* head); #endif