更新合并函数
This commit is contained in:
parent
7935f0fbe0
commit
cd0fee3b69
@ -1,2 +1,4 @@
|
|||||||
main.c
|
main.c
|
||||||
|
sq_list.c
|
||||||
|
正在生成代码...
|
||||||
Project2.vcxproj -> C:\code\lencode\Project2\Debug\Project2.exe
|
Project2.vcxproj -> C:\code\lencode\Project2\Debug\Project2.exe
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
22
sq_list.c
22
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[i + 1] = list->data[i];
|
||||||
}
|
}
|
||||||
list->data[pos] = value;
|
list->data[pos] = value;
|
||||||
if (flog + 1 > list->length)
|
/* if (flog + 1 > list->length)*/
|
||||||
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 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])
|
if (list_1->data[j] != list_2->data[i])
|
||||||
continue;
|
|
||||||
else if (list_1->data[j] == list_2->data[i])
|
|
||||||
{
|
{
|
||||||
flog++; break;
|
if (j == list_1->length -1)
|
||||||
}
|
{
|
||||||
else
|
list_1->data[list_1->length] = list_2->data[i];
|
||||||
{
|
list_1->length++;
|
||||||
list_1->data[list_1->length] = list_2->data[i];
|
flog++;
|
||||||
list_1->length++;
|
}
|
||||||
|
else
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
printf("----------------------------------\n");
|
printf("----------------------------------\n");
|
||||||
printf("有%d相同 有%d不相同\n", flog, list_2->length - flog);
|
printf("有%d不相同 有%d相同\n", flog, list_2->length - flog);
|
||||||
printf("----------------------------------\n");
|
printf("----------------------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user