更新合并函数
This commit is contained in:
parent
7935f0fbe0
commit
cd0fee3b69
@ -1,2 +1,4 @@
|
||||
main.c
|
||||
sq_list.c
|
||||
正在生成代码...
|
||||
Project2.vcxproj -> C:\code\lencode\Project2\Debug\Project2.exe
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
14
sq_list.c
14
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++;
|
||||
}
|
||||
|
||||
@ -96,21 +96,21 @@ void merge_sq_list(sq_list* list_1, sq_list* list_2)
|
||||
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
|
||||
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");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user