队列print 更新

This commit is contained in:
Jdhggg 2025-03-24 21:08:31 +08:00
parent 1633ab47cb
commit 087cd9e36c
10 changed files with 57 additions and 47 deletions

View File

@ -0,0 +1,20 @@
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\linked_list_stack.obj
c:\code\lencode\project2\project2\debug\linked_list.obj
c:\code\lencode\project2\project2\debug\array_stack.obj
c:\code\lencode\project2\project2\debug\array_queue.obj
c:\code\lencode\project2\project2\debug\main.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\main.obj.enc
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

@ -1,25 +1,7 @@
 array_queue.c  array_queue.c
array_stack.c
C:\code\lencode\Project2\array_queue.c(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 C:\code\lencode\Project2\array_queue.c(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
C:\code\lencode\Project2\array_queue.h(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 C:\code\lencode\Project2\array_queue.h(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
(编译源文件“array_queue.c”) (编译源文件“array_queue.c”)
C:\code\lencode\Project2\array_queue.c(22,5): warning C4013: “memset”未定义假设外部返回 int C:\code\lencode\Project2\array_queue.c(22,5): warning C4013: “memset”未定义假设外部返回 int
C:\code\lencode\Project2\array_stack.c(12,5): warning C4013: “memset”未定义假设外部返回 int
linked_list.c
linked_list_stack.c
C:\code\lencode\Project2\linked_list_stack.c(26,3): warning C4098: “push_stack_linked”:“void”函数返回值
main.c
C:\code\lencode\Project2\array_queue.h(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
(编译源文件“main.c”)
C:\code\lencode\Project2\main.c(37,22): warning C4013: “init_array_queue”未定义假设外部返回 int
C:\code\lencode\Project2\main.c(37,18): warning C4047: “初始化”:“array_queue *”与“int”的间接级别不同
sq_list.c
C:\code\lencode\Project2\sq_list.c(102,9): warning C4033: “locate_list”必须返回值
C:\code\lencode\Project2\sq_list.c(112,9): warning C4033: “locate_list”必须返回值
C:\code\lencode\Project2\sq_list.c(166,34): warning C4047: “函数”:“int”与“sq_list *”的间接级别不同
C:\code\lencode\Project2\sq_list.c(166,34): warning C4024: “locate_list”: 形参和实参 2 的类型不同
正在生成代码...
C:\code\lencode\Project2\sq_list.c(116,1): warning C4715: “locate_list”: 不是所有的控件路径都返回值
Project2.vcxproj -> C:\code\lencode\Project2\Debug\Project2.exe Project2.vcxproj -> C:\code\lencode\Project2\Debug\Project2.exe

Binary file not shown.

View File

@ -7,7 +7,7 @@
,rear == size时,[0],`` ,rear == size时,[0],``
## 实现思路: ## 实现思路:
,使rear和front都在数组的[0,size-1],. ,使rear和front都在数组的[0,size-1],.
# 点解析: # 点解析:
使\n 使\n
使使 使使
@-------------*/ @-------------*/
@ -50,7 +50,7 @@ void push_array_queue(array_queue *q, elem_type value)
if (full_array_queue(q)) if (full_array_queue(q))
{printf("error: queue is full[From push_queue]"); return;} {printf("error: queue is full[From push_queue]"); return;}
q->data[q->rear] = value; q->data[q->rear] = value;
q->rear = (q->front + q->size + 1) % MAX_QUEUE; q->rear = (q->front + q->size +1) % MAX_QUEUE;
q->size++; q->size++;
} }
@ -73,14 +73,15 @@ void print_array_queue(array_queue *q)
printf("error :\n"); printf("error :\n");
return ; return ;
} }
for (int i=q->front; i!=q->rear;i = (i+1)%MAX_QUEUE) for (int i=q->front;i<q->size;i++)
{ {
printf("["); printf("[");
printf("%d ",q->data[i]); printf("%d ",q->data[i%MAX_QUEUE]);
printf("]\n"); printf("]\n");
} }
} }
// void return def => fuck shit
// if while for void return fuck shit def sleep // if for while malloc def sleep pause NULL
// #include $time_noon

View File

@ -6,6 +6,11 @@
node* init_node(elem_type value) node* init_node(elem_type value)
{ {
node* new_node = (node*)malloc(sizeof(node)); node* new_node = (node*)malloc(sizeof(node));
if (new_node == NULL)
{
printf("error: malloc failed\n");
return NULL;
}
new_node->value = value; new_node->value = value;
new_node->next = NULL; new_node->next = NULL;
return new_node; return new_node;

48
main.c
View File

@ -10,41 +10,43 @@ int main(void)
//sq_list* L = init_sq_list(); /*sq_list* L = init_sq_list();
//sq_list* N = init_sq_list(); sq_list* N = init_sq_list();
//for (int i = 1; i <= 3; i++) for (int i = 1; i <= 3; i++)
//{ {
// N->data[i - 1] = i+10; N->data[i - 1] = i+10;
//} }
//for (int i = 1; i <= 10; i++) for (int i = 1; i <= 10; i++)
//{ {
// L->data[i - 1] = i; L->data[i - 1] = i;
//} }
//N->length = 3; N->length = 3;
//L->length = 10; L->length = 10;
//print_sq_list(N); print_sq_list(N);
//print_sq_list(L); print_sq_list(L);
//mer_ge_sq_list(L,N); mer_ge_sq_list(L,N);
//print_sq_list(L); print_sq_list(L);
//printf("L->length:[%d]\n", L->length); printf("L->length:[%d]\n", L->length);*/
/*
// ջ<><D5BB><EFBFBD><EFBFBD> /* array_stack* stack = init_array_stack();
array_stack* stack = init_array_stack();
push_array_stack(stack, 1); push_array_stack(stack, 1);
push_array_stack(stack, 2); push_array_stack(stack, 2);
push_array_stack(stack, 3); */ push_array_stack(stack, 3);*/
array_queue *q = init_array_queue(); array_queue *q = init_array_queue();
push_array_queue(q,0); push_array_queue(q,0);
push_array_queue(q,1); push_array_queue(q,1);
push_array_queue(q,2); push_array_queue(q,2);
print_array_queue(q); print_array_queue(q);
printf("---------------------\n"); printf("---------------------\n");
pop_array_queue(q); /* pop_array_queue(q);
print_array_queue(q); print_array_queue(q);
printf("----------\n"); printf("----------\n");
push_array_queue(q, 666); push_array_queue(q, 666);
print_array_queue(q); print_array_queue(q);*/
printf("Hello World!\n"); printf("Hello World!\n");
system("pause"); system("pause");
return 0; return 0;