队列print 更新
This commit is contained in:
parent
1633ab47cb
commit
087cd9e36c
@ -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
|
@ -1,25 +1,7 @@
|
||||
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.h(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
|
||||
(编译源文件“array_queue.c”)
|
||||
|
||||
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
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Project2/Debug/array_queue.obj.enc
Normal file
BIN
Project2/Debug/array_queue.obj.enc
Normal file
Binary file not shown.
@ -7,7 +7,7 @@
|
||||
设计圆环式队列,当rear == size时,循环到数组的[0]位,当然这样的队列仍然遵循`先进先出原则`
|
||||
## 实现思路:
|
||||
通过取模运算,使得rear和front都在数组的[0,size-1]范围内,这样就能实现循环队列的功能.
|
||||
# 优点解析:
|
||||
# 有点解析:
|
||||
在传统的队列中,当队尾到达队列的末尾时,即使队列前面还有空闲空间,也无法继续入队,导致空间浪费。而环形队列通过取模运算,\n
|
||||
使得队尾指针可以在到达队列末尾后,从头开始继续使用队列的空闲空间,从而提高了空间的利用率。
|
||||
@-------------*/
|
||||
@ -50,7 +50,7 @@ void push_array_queue(array_queue *q, elem_type value)
|
||||
if (full_array_queue(q))
|
||||
{printf("error: queue is full[From push_queue]"); return;}
|
||||
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++;
|
||||
}
|
||||
|
||||
@ -73,14 +73,15 @@ void print_array_queue(array_queue *q)
|
||||
printf("error :\n");
|
||||
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("%d ",q->data[i]);
|
||||
printf("%d ",q->data[i%MAX_QUEUE]);
|
||||
printf("]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if while for void return fuck shit def sleep
|
||||
// void return def => fuck shit
|
||||
// if for while malloc def sleep pause NULL
|
||||
// #include $time_noon
|
@ -6,6 +6,11 @@
|
||||
node* init_node(elem_type value)
|
||||
{
|
||||
node* new_node = (node*)malloc(sizeof(node));
|
||||
if (new_node == NULL)
|
||||
{
|
||||
printf("error: malloc failed\n");
|
||||
return NULL;
|
||||
}
|
||||
new_node->value = value;
|
||||
new_node->next = NULL;
|
||||
return new_node;
|
||||
|
48
main.c
48
main.c
@ -10,41 +10,43 @@ int main(void)
|
||||
|
||||
|
||||
|
||||
//sq_list* L = init_sq_list();
|
||||
//sq_list* N = init_sq_list();
|
||||
//for (int i = 1; i <= 3; i++)
|
||||
//{
|
||||
// N->data[i - 1] = i+10;
|
||||
//}
|
||||
//for (int i = 1; i <= 10; i++)
|
||||
//{
|
||||
// L->data[i - 1] = i;
|
||||
//}
|
||||
//N->length = 3;
|
||||
//L->length = 10;
|
||||
//print_sq_list(N);
|
||||
//print_sq_list(L);
|
||||
//mer_ge_sq_list(L,N);
|
||||
//print_sq_list(L);
|
||||
//printf("L->length:[%d]\n", L->length);
|
||||
/*sq_list* L = init_sq_list();
|
||||
sq_list* N = init_sq_list();
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
N->data[i - 1] = i+10;
|
||||
}
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
L->data[i - 1] = i;
|
||||
}
|
||||
N->length = 3;
|
||||
L->length = 10;
|
||||
print_sq_list(N);
|
||||
print_sq_list(L);
|
||||
mer_ge_sq_list(L,N);
|
||||
print_sq_list(L);
|
||||
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, 2);
|
||||
push_array_stack(stack, 3); */
|
||||
push_array_stack(stack, 3);*/
|
||||
|
||||
|
||||
|
||||
array_queue *q = init_array_queue();
|
||||
push_array_queue(q,0);
|
||||
push_array_queue(q,1);
|
||||
push_array_queue(q,2);
|
||||
print_array_queue(q);
|
||||
printf("---------------------\n");
|
||||
pop_array_queue(q);
|
||||
/* pop_array_queue(q);
|
||||
print_array_queue(q);
|
||||
printf("----------\n");
|
||||
push_array_queue(q, 666);
|
||||
print_array_queue(q);
|
||||
print_array_queue(q);*/
|
||||
printf("Hello World!\n");
|
||||
system("pause");
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user