习题33完成了

This commit is contained in:
Wang Bo Yang 2025-06-07 19:10:11 +08:00
parent 675c27e572
commit 32eaa2be85
6 changed files with 7 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View File

@ -328,12 +328,12 @@ void merge2(List *a, char aux[][6], int m, int n, int lo, int mid, int hi, List_
}
printf("%s%s\n", "cur -> value", cur -> value);
// printf("%s%s\n", "cur -> value", cur -> value);
// copy to aux[]
for (int k = lo; k <= hi && cur != NULL; ++k)
{
puts("1");
printf("%s%s\n", "aux[k]: ", aux[k]);
//puts("1");
// printf("%s%s\n", "aux[k]: ", aux[k]);
strcpy(aux[k], cur -> value);
// 保证cur->value长度不超过4,不含\0手动实现复制功能

Binary file not shown.

Binary file not shown.

View File

@ -117,7 +117,7 @@ char *test_bubble_sort()
{
List *words = create_words2();
List *empty_list = List_create();
int count = 100;
int count = 10000;
// should work on a list that needs sorting
int rc = List_bubble_sort(words, (List_compare)strcmp);
@ -176,13 +176,13 @@ char *test_insert()
char *test_merge_sort()
{
List *words = create_words2();
int count = 100;
int count = 10000;
// should work on a list that needs sorting
List *res = List_merge_sort2(words, (List_compare)strcmp);
ZED_MU_ASSERT_MACRO(!is_sorted(res), "Words are not sorted after merge sort.");
List *res2 = List_merge_sort(res, (List_compare) strcmp);
List *res2 = List_merge_sort2(res, (List_compare) strcmp);
ZED_MU_ASSERT_MACRO(!is_sorted(res2), "Should still be sorted after merge sort.");
clock_t start = clock();
@ -190,7 +190,7 @@ char *test_merge_sort()
while (count > 0)
{
List_reverse(words);
List_merge_sort(words, (List_compare)strcmp);
List_merge_sort2(words, (List_compare)strcmp);
--count;
}