From 7935f0fbe0133ec7b29dae0727672f748b8e8ceb Mon Sep 17 00:00:00 2001 From: Jdhggg <24016020834@stu.nsu.edu.cn> Date: Thu, 20 Mar 2025 23:34:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project2/Debug/Project2.log | 2 +- .../Debug/Project2.tlog/CL.command.1.tlog | Bin 2958 -> 2958 bytes Project2/Debug/Project2.tlog/CL.read.1.tlog | Bin 13514 -> 13514 bytes Project2/Debug/Project2.tlog/CL.write.1.tlog | Bin 4354 -> 4354 bytes main.c | 4 ++-- sq_list.c | 4 ++++ 6 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Project2/Debug/Project2.log b/Project2/Debug/Project2.log index 976bffc..259d036 100644 --- a/Project2/Debug/Project2.log +++ b/Project2/Debug/Project2.log @@ -1,2 +1,2 @@ - sq_list.c + main.c 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 63d02921de1fab87535df6fd4037ea928c5a202a..5c9a976e2c6a6a350957d2dd3674b2b7fd78b10b 100644 GIT binary patch delta 17 ZcmeAZ?-So3$F}(u#}cN^uUOA80RTJg2HF4s delta 25 dcmeAZ?-So3$2Pf+TVS&Xa|IKa@rv~Z698%J2x|ZU diff --git a/Project2/Debug/Project2.tlog/CL.read.1.tlog b/Project2/Debug/Project2.tlog/CL.read.1.tlog index 161a88492354ac7594a396cc8088bac5aa07e7a8..0ee1b329dc02914d2336ef9db6c6adfa2fb365d6 100644 GIT binary patch delta 21 dcmX?=c`9?m64A|msx|zRrBqEeFA*){2LNkJ2zUSh delta 28 kcmX?=c`9?m64A{es%89>6;w?obEyhU^yArlKs13L0IBQ>K>z>% diff --git a/Project2/Debug/Project2.tlog/CL.write.1.tlog b/Project2/Debug/Project2.tlog/CL.write.1.tlog index cd2bbd56fdd2870579d2bf0afea9de24cd9eb5e9..5e17f1198edf405d0a3b628a9a73c293e582d897 100644 GIT binary patch delta 17 YcmZotYEs(Z#J4$)$A@tV!Z diff --git a/main.c b/main.c index ae7d234..856879f 100644 --- a/main.c +++ b/main.c @@ -22,10 +22,10 @@ int main(void) L->length = 10; print_sq_list(N); print_sq_list(L); - printf("----------------------------------"); merge_sq_list(N,L); print_sq_list(L); - printf("%d", L->length); + printf("L->length:[%d]\n", L->length); printf("Hello World!\n"); + system("pause"); return 0; } diff --git a/sq_list.c b/sq_list.c index 658c42f..a4ac840 100644 --- a/sq_list.c +++ b/sq_list.c @@ -72,8 +72,10 @@ void insert_sq_list(sq_list* list, int pos, int value) // ӡ void print_sq_list(sq_list* list) { + printf("["); for (int i = 0; i < list->length; i++) printf("%d ", list->data[i]); + printf("]"); printf("\n"); } @@ -107,7 +109,9 @@ void merge_sq_list(sq_list* list_1, sq_list* list_2) } } + printf("----------------------------------\n"); printf("%dͬ %dͬ\n", flog, list_2->length - flog); + printf("----------------------------------\n"); } //if (list_1->data[j] != list_2->data[i]) From cd0fee3b699311298716c4f70310561d0b82e1ae Mon Sep 17 00:00:00 2001 From: Jdhggg <24016020834@stu.nsu.edu.cn> Date: Fri, 21 Mar 2025 00:59:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project2/Debug/Project2.log | 2 ++ .../Debug/Project2.tlog/CL.command.1.tlog | Bin 2958 -> 2958 bytes Project2/Debug/Project2.tlog/CL.read.1.tlog | Bin 13514 -> 12738 bytes Project2/Debug/Project2.tlog/CL.write.1.tlog | Bin 4354 -> 3944 bytes sq_list.c | 22 +++++++++--------- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Project2/Debug/Project2.log b/Project2/Debug/Project2.log index 259d036..864d6f9 100644 --- a/Project2/Debug/Project2.log +++ b/Project2/Debug/Project2.log @@ -1,2 +1,4 @@  main.c + sq_list.c + 正在生成代码... 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 5c9a976e2c6a6a350957d2dd3674b2b7fd78b10b..63d02921de1fab87535df6fd4037ea928c5a202a 100644 GIT binary patch delta 25 dcmeAZ?-So3$2Pf+TVS&Xa|IKa@rv~Z698%J2x|ZU delta 17 ZcmeAZ?-So3$F}(u#}cN^uUOA80RTJg2HF4s diff --git a/Project2/Debug/Project2.tlog/CL.read.1.tlog b/Project2/Debug/Project2.tlog/CL.read.1.tlog index 0ee1b329dc02914d2336ef9db6c6adfa2fb365d6..48850f0118d0a23e75ea6b0a6fb03dec1a78536f 100644 GIT binary patch delta 34 ocmX?=c_?|q64A*as$!e#xaV+gexOjoGMP(NV58p(5XXT9005>9X#fBK delta 424 zcmX?Re1L2x21g+6$q)skLx8kD zP)!U_-k%`|%=ZJTL-1V~Tp8SeDno&KLKyUbYJC`jCx6smIr#~fLbwrw0fQ-n5m3D| zP&^c9njX+TA0Xsq-~x(S0cFr#5zG(?v@HZ^t}lZzSZ@f>EkQtjFiiL4Lhas7JW`yK WKd?7!z9#>LdGZobv0>w#1Iz$`T~c)b diff --git a/Project2/Debug/Project2.tlog/CL.write.1.tlog b/Project2/Debug/Project2.tlog/CL.write.1.tlog index 5e17f1198edf405d0a3b628a9a73c293e582d897..f8a0555a6e2cfb6ccf6c1533844a180bb5975868 100644 GIT binary patch delta 23 ecmZotdLg&LiEpwT56|QV=B&wD943?FcxnJ%5eH@f delta 24 gcmaDM*QB(;iEncpj}PNyKE73x9T>MwPGAxN0Bk}C0RR91 diff --git a/sq_list.c b/sq_list.c index a4ac840..3d69003 100644 --- a/sq_list.c +++ b/sq_list.c @@ -62,7 +62,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) + /* if (flog + 1 > list->length)*/ list->length++; } @@ -93,24 +93,24 @@ void merge_sq_list(sq_list* list_1, sq_list* list_2) for (int i = 0; i < list_2->length; i++) { - for (int j = 0; j < list_1->length; j++) + for (int j = 0; j < list_1->length; j++) { if (list_1->data[j] != list_2->data[i]) - continue; - else if (list_1->data[j] == list_2->data[i]) { - flog++; break; - } - else - { - list_1->data[list_1->length] = list_2->data[i]; - list_1->length++; + if (j == list_1->length -1) + { + list_1->data[list_1->length] = list_2->data[i]; + list_1->length++; + flog++; + } + else + continue; } } } printf("----------------------------------\n"); - printf("%dͬ %dͬ\n", flog, list_2->length - flog); + printf("%dͬ %dͬ\n", flog, list_2->length - flog); printf("----------------------------------\n"); } From 3b42b940e703849460ffc981592d0e82ae8275ba Mon Sep 17 00:00:00 2001 From: Jdhggg <24016020834@stu.nsu.edu.cn> Date: Fri, 21 Mar 2025 01:00:13 +0800 Subject: [PATCH 3/3] Update main.c --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 856879f..347e136 100644 --- a/main.c +++ b/main.c @@ -12,7 +12,7 @@ int main(void) sq_list* N = init_sq_list(); for (int i = 1; i <= 3; i++) { - N->data[i - 1] = i; + N->data[i - 1] = i+10; } for (int i = 1; i <= 10; i++) { @@ -23,8 +23,8 @@ int main(void) print_sq_list(N); print_sq_list(L); merge_sq_list(N,L); - print_sq_list(L); - printf("L->length:[%d]\n", L->length); + print_sq_list(N); + printf("L->length:[%d]\n", N->length); printf("Hello World!\n"); system("pause"); return 0;