commit
809f633b34
@ -18,15 +18,15 @@
|
|||||||
<ClCompile Include="main.c">
|
<ClCompile Include="main.c">
|
||||||
<Filter>源文件</Filter>
|
<Filter>源文件</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="sq_list.c">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="linked_list.c">
|
<ClCompile Include="linked_list.c">
|
||||||
<Filter>源文件</Filter>
|
<Filter>源文件</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="linked_list_stack.c">
|
<ClCompile Include="linked_list_stack.c">
|
||||||
<Filter>源文件</Filter>
|
<Filter>源文件</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="sq_list.c">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="sq_list.h">
|
<ClInclude Include="sq_list.h">
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
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.
Binary file not shown.
BIN
Project2/Debug/main.obj.enc
Normal file
BIN
Project2/Debug/main.obj.enc
Normal file
Binary file not shown.
BIN
Project2/Debug/sq_list.obj.enc
Normal file
BIN
Project2/Debug/sq_list.obj.enc
Normal file
Binary file not shown.
54
sq_list.c
54
sq_list.c
@ -27,6 +27,7 @@ void delete_sq_list(sq_list* list,int pos)
|
|||||||
list->data[list->length - 1] = 0;
|
list->data[list->length - 1] = 0;
|
||||||
}
|
}
|
||||||
list->length--;
|
list->length--;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ìæ»»
|
// Ìæ»»
|
||||||
@ -79,6 +80,43 @@ void print_sq_list(sq_list* list)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获得元素
|
||||||
|
void get_sq_list(sq_list* list1, int pos, int*e)
|
||||||
|
{
|
||||||
|
if (list1->length == 0 || pos<0 || pos>list1->length)
|
||||||
|
{
|
||||||
|
printf("获取元素失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*e = list1->data[pos];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//查找
|
||||||
|
int locate_list(sq_list* list, int *e)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
if (list->length == 0)
|
||||||
|
{
|
||||||
|
printf("表长为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (i = 0;i < list->length;i++)
|
||||||
|
{
|
||||||
|
if (list->data[i] == e)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (i > list->length)
|
||||||
|
{
|
||||||
|
printf("越界错误");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 2 µ½ 1
|
// 2 µ½ 1
|
||||||
void merge_sq_list(sq_list* list_1, sq_list* list_2)
|
void merge_sq_list(sq_list* list_1, sq_list* list_2)
|
||||||
{
|
{
|
||||||
@ -117,4 +155,18 @@ void merge_sq_list(sq_list* list_1, sq_list* list_2)
|
|||||||
//if (list_1->data[j] != list_2->data[i])
|
//if (list_1->data[j] != list_2->data[i])
|
||||||
//continue;
|
//continue;
|
||||||
//else if (list_1->data[j] == list_2->data[i])
|
//else if (list_1->data[j] == list_2->data[i])
|
||||||
//break;
|
//break;
|
||||||
|
|
||||||
|
//合并2.0
|
||||||
|
void mer_ge_sq_list(sq_list* list_1, sq_list* list_2)
|
||||||
|
{
|
||||||
|
int e;
|
||||||
|
int k = 0;
|
||||||
|
for (int k=0;k < list_2->length;k++)
|
||||||
|
{
|
||||||
|
get_sq_list(list_2, k, &e);
|
||||||
|
if (!locate_list(list_1, list_2))
|
||||||
|
insert_sq_list(list_1, list_1->length, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
10
sq_list.h
10
sq_list.h
@ -24,8 +24,16 @@ void insert_sq_list(sq_list* list, int pos, int value);
|
|||||||
// ´òÓ¡
|
// ´òÓ¡
|
||||||
void print_sq_list(sq_list* list);
|
void print_sq_list(sq_list* list);
|
||||||
|
|
||||||
// 合并顺序表
|
//»ñµÃÔªËØ
|
||||||
|
void get_sq_list(sq_list* list1,int pos, int *e);
|
||||||
|
|
||||||
|
//²éÕÒ
|
||||||
|
int locate_list(sq_list* list, int e);
|
||||||
|
|
||||||
|
// ºÏ²¢Ë³Ðò±í1.0
|
||||||
void merge_sq_list(sq_list* list_1, sq_list* list_2);
|
void merge_sq_list(sq_list* list_1, sq_list* list_2);
|
||||||
|
|
||||||
|
//ºÏ²¢Ë³Ðò±í2.0
|
||||||
|
void mer_ge_sq_list(sq_list* list_1, sq_list* list_2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user