sq_list显示优化

This commit is contained in:
Jdhggg 2025-03-21 12:31:38 +08:00
parent 1f6ac179b9
commit ff8b779b7b
11 changed files with 32 additions and 9 deletions

View File

@ -0,0 +1,17 @@
c:\code\lencode\project2\project2\debug\vc143.pdb
c:\code\lencode\project2\project2\debug\vc143.idb
c:\code\lencode\project2\project2\debug\sq_list.obj
c:\code\lencode\project2\project2\debug\main.obj
c:\code\lencode\project2\project2\debug\linked_list_stack.obj
c:\code\lencode\project2\project2\debug\linked_list.obj
c:\code\lencode\project2\debug\project2.exe
c:\code\lencode\project2\debug\project2.pdb
c:\code\lencode\project2\project2\debug\project2.ilk
c:\code\lencode\project2\project2\debug\project2.tlog\cl.command.1.tlog
c:\code\lencode\project2\project2\debug\project2.tlog\cl.items.tlog
c:\code\lencode\project2\project2\debug\project2.tlog\cl.read.1.tlog
c:\code\lencode\project2\project2\debug\project2.tlog\cl.write.1.tlog
c:\code\lencode\project2\project2\debug\project2.tlog\link.command.1.tlog
c:\code\lencode\project2\project2\debug\project2.tlog\link.read.1.tlog
c:\code\lencode\project2\project2\debug\project2.tlog\link.secondary.1.tlog
c:\code\lencode\project2\project2\debug\project2.tlog\link.write.1.tlog

View File

@ -0,0 +1,2 @@
 main.c
Project2.vcxproj -> C:\code\lencode\Project2\Debug\Project2.exe

Binary file not shown.

Binary file not shown.

6
main.c
View File

@ -22,9 +22,9 @@ int main(void)
L->length = 10;
print_sq_list(N);
print_sq_list(L);
merge_sq_list(N,L);
print_sq_list(N);
printf("L->length:[%d]\n", N->length);
mer_ge_sq_list(L,N);
print_sq_list(L);
printf("L->length:[%d]\n", L->length);
printf("Hello World!\n");
system("pause");
return 0;

View File

@ -64,7 +64,7 @@ void insert_sq_list(sq_list* list, int pos, int value)
}
list->data[pos] = value;
/* if (flog + 1 > list->length)*/
list->length++;
list->length++;
}
@ -117,7 +117,7 @@ int locate_list(sq_list* list, int *e)
// 2 µ½ 1
// 2 到 1 合并
void merge_sq_list(sq_list* list_1, sq_list* list_2)
{
if (list_1->length == 0 || list_2->length == 0)
@ -152,21 +152,25 @@ void merge_sq_list(sq_list* list_1, sq_list* list_2)
printf("----------------------------------\n");
}
//if (list_1->data[j] != list_2->data[i])
//continue;
//else if (list_1->data[j] == list_2->data[i])
//break;
//ºÏ²¢2.0
void mer_ge_sq_list(sq_list* list_1, sq_list* list_2)
{
int e;
int k = 0;
int flog = 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);
flog++;
}
}
printf("----------------------------------\n");
printf("有%d不相同 有%d相同\n", flog, list_2->length - flog);
printf("----------------------------------\n");
}