From 7cace1073e6ea84c6f38ace3714555f2bc56cf81 Mon Sep 17 00:00:00 2001 From: Jdhggg <24016020834@stu.nsu.edu.cn> Date: Mon, 17 Mar 2025 17:08:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=BE=E8=A1=A8=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project2/Debug/Project2.log | 5 +- .../Debug/Project2.tlog/CL.command.1.tlog | Bin 2190 -> 2190 bytes Project2/Debug/Project2.tlog/CL.read.1.tlog | Bin 10650 -> 11038 bytes Project2/Debug/Project2.tlog/CL.write.1.tlog | Bin 2130 -> 2346 bytes linked_list.c | 44 +++++++++++++++++- linked_list.h | 12 ++++- 6 files changed, 56 insertions(+), 5 deletions(-) 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 9ca4aac48986ba7ddbb4b63363ce9a305b2317ae..cc68b3cdcaa2f2cc629605e2ac5999e87a872c58 100644 GIT binary patch delta 27 gcmeAZ>=T?|wpot3fOYaKCX>l$nB+FGRWN~Q0D~k6F#rGn delta 33 pcmeAZ>=T?|Ho1U9Zu1Y;X-t!sv6@WY$0V>>g1Lfe^FF2*OaRQ?3-AB{ diff --git a/Project2/Debug/Project2.tlog/CL.read.1.tlog b/Project2/Debug/Project2.tlog/CL.read.1.tlog index d321be297d4dd37a10b8cca16f8e596cbea8f1cc..ab688c70c63c3519a271c0c409a51bf3ddac298c 100644 GIT binary patch delta 37 tcmbOgJTGj5+2#^1HTlU7TqYCER5o{UDR58r;L@3BCc);xz{|kJ008NS3E=<$ delta 27 jcmbOiHY<37+2jfGDwE%+HErIdn8G=E4Zq1oGc|btrP2!C diff --git a/Project2/Debug/Project2.tlog/CL.write.1.tlog b/Project2/Debug/Project2.tlog/CL.write.1.tlog index d4dd94b717a29cfc0ff32c5f8fb34cdd10d72dac..026ce36fd251afa3a71d95318d2a60100cff6bf3 100644 GIT binary patch delta 23 fcmca4uu5pdEtbubSPw8wUdFOx67#mnEi6g^e1r+M delta 16 YcmZ1_bV*>tEtbjW*jqL)WBI}a06@V9YybcN 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