Merge pull request #1 from jdhnsu/main_dyc

Main dyc
This commit is contained in:
蒋东桓 2025-03-21 01:47:40 +08:00 committed by GitHub
commit 809f633b34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 65 additions and 9 deletions

View File

@ -18,15 +18,15 @@
<ClCompile Include="main.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="sq_list.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="linked_list.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="linked_list_stack.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="sq_list.c">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="sq_list.h">

View File

@ -1,4 +0,0 @@
 main.c
sq_list.c
正在生成代码...
Project2.vcxproj -> C:\code\lencode\Project2\Debug\Project2.exe

BIN
Project2/Debug/main.obj.enc Normal file

Binary file not shown.

Binary file not shown.

View File

@ -27,6 +27,7 @@ void delete_sq_list(sq_list* list,int pos)
list->data[list->length - 1] = 0;
}
list->length--;
}
// Ìæ»»
@ -79,6 +80,43 @@ void print_sq_list(sq_list* list)
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
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])
//continue;
//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);
}
}

View File

@ -24,8 +24,16 @@ void insert_sq_list(sq_list* list, int pos, int value);
// ´òÓ¡
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);
//ºÏ²¢Ë³Ðò±í2.0
void mer_ge_sq_list(sq_list* list_1, sq_list* list_2);
#endif