From 60b1d8e65a0b71f4da036367097ae8700bccabdd Mon Sep 17 00:00:00 2001 From: Jdhggg <24016020834@stu.nsu.edu.cn> Date: Mon, 17 Mar 2025 16:27:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project2.vcxproj | 2 ++ Project2.vcxproj.filters | 6 ++++ .../Debug/Project2.tlog/CL.command.1.tlog | Bin 1446 -> 2190 bytes Project2/Debug/Project2.tlog/CL.read.1.tlog | Bin 7640 -> 10650 bytes Project2/Debug/Project2.tlog/CL.write.1.tlog | Bin 1002 -> 2130 bytes Project2/Debug/Project2.tlog/Cl.items.tlog | 1 + .../Debug/Project2.tlog/link.command.1.tlog | Bin 1314 -> 1490 bytes Project2/Debug/Project2.tlog/link.read.1.tlog | Bin 3274 -> 3500 bytes .../Debug/Project2.tlog/link.secondary.1.tlog | 2 +- .../Debug/Project2.tlog/link.write.1.tlog | Bin 388 -> 500 bytes linked_list.c | 28 ++++++++++++++++ linked_list.h | 31 ++++++++++++++++++ main.c | 5 ++- sq_list.c | 1 + 14 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 linked_list.c create mode 100644 linked_list.h diff --git a/Project2.vcxproj b/Project2.vcxproj index 3e14bd7..0456f2b 100644 --- a/Project2.vcxproj +++ b/Project2.vcxproj @@ -19,10 +19,12 @@ + + diff --git a/Project2.vcxproj.filters b/Project2.vcxproj.filters index 241c01e..cb26a7d 100644 --- a/Project2.vcxproj.filters +++ b/Project2.vcxproj.filters @@ -21,10 +21,16 @@ 源文件 + + 源文件 + 头文件 + + 头文件 + \ No newline at end of file diff --git a/Project2/Debug/Project2.tlog/CL.command.1.tlog b/Project2/Debug/Project2.tlog/CL.command.1.tlog index c52f65641cffa294cff076236027b6c3b36129ed..ce6de68021b9ee21902090c69b17752da7011161 100644 GIT binary patch delta 42 ncmZ3+-6uG~jN6C7lfjR{o57XAWus*`6Ec7DaVGbTW(BMO(*6n& delta 11 ScmeAZT*f`YY_lA50V@C(76V`a diff --git a/Project2/Debug/Project2.tlog/CL.read.1.tlog b/Project2/Debug/Project2.tlog/CL.read.1.tlog index 56403d6680c5ecfa77f2575d6ae20142a47364df..10b84e4a78efe30b509dd81a8c43fc2cd1eb313b 100644 GIT binary patch delta 56 zcmca%Ju7&E8MhCECxah@H-jsK%SOwsoRi=1>L80vmgaMxEWszRIfpNYf3qInDt-X8 CgAT_4 delta 19 bcmbOge8YNz+2mW20vr8SaBkip`bro8SOExv diff --git a/Project2/Debug/Project2.tlog/CL.write.1.tlog b/Project2/Debug/Project2.tlog/CL.write.1.tlog index 8d9524e3fecda029d1aeada5976c19e2087da397..2d403bc8681d021ee4ccefd1a21864c18b2b85c2 100644 GIT binary patch delta 92 zcmaFGeo0`%H%3t(22Tb*25$ye1{a2S1`scpA!MSh<>XaNJR6-F7$>(ervPyPH=lxkh?Ih^P;PCxah@H-jsK3qw2uh!@NdGBG-OW5@;$ZY0Uc*_^VIE|WaAM7MgSOB1PK5D diff --git a/linked_list.c b/linked_list.c new file mode 100644 index 0000000..ddd4769 --- /dev/null +++ b/linked_list.c @@ -0,0 +1,28 @@ +#include +#include +#include "linked_list.h" + + + +// ʼֵ +node* init_node(int val) +{ + node* new_node = (node*)malloc(sizeof(node)); + new_node->value = val; + new_node->next = NULL; + return new_node; +} + + +// ɾһڵ +void delete_node(node* n) +{ + n->next = n->next->next; + free(n->next); +} + +// 滻ڵֵ +void replace_node(node* n, int val) +{ + +} diff --git a/linked_list.h b/linked_list.h new file mode 100644 index 0000000..c170697 --- /dev/null +++ b/linked_list.h @@ -0,0 +1,31 @@ +#ifndef LINKED_LIST_H +#define LINKED_LIST_H + +typedef struct node +{ + int value; + struct node* next; +} node; + +// ʼڵ +node* init_node(int val); + +// ɾһڵ +void delete_node(node* n); + +// 滻ڵ +void replace_node (node* n, int val); + +// ڵ +void insert_node(node** head, int val); + +//ʽڵ +int get_node(node* n); + +// +int find_node(node* head, int val); + + + +#endif + diff --git a/main.c b/main.c index 5ba5422..26aee53 100644 --- a/main.c +++ b/main.c @@ -7,8 +7,11 @@ int main(void) { sq_list *list = init_sq_list(&list); + for (int i = 0; i < 5; i++) { + list->data[i] = i; + } list->length = 6; - replace_sq_list(list, 2, 5); + insert_sq_list(list, 3, 666); print_sq_list(list); printf("Hello World!\n"); return 0; diff --git a/sq_list.c b/sq_list.c index b245db8..9325888 100644 --- a/sq_list.c +++ b/sq_list.c @@ -60,6 +60,7 @@ void insert_sq_list(sq_list* list, int pos, int value) { list->data[i + 1] = list->data[i]; } + list->data[pos] = value; if (flog + 1 > list->length) list->length++; }