Compare commits
No commits in common. "fc334bbfca2234f8d62225c43bb5b005ef3a2923" and "cf39e5499fd0d9c499fe575b43fd5e6ad037949d" have entirely different histories.
fc334bbfca
...
cf39e5499f
8
.gitignore
vendored
8
.gitignore
vendored
@ -57,11 +57,3 @@ dkms.conf
|
|||||||
*.recipe
|
*.recipe
|
||||||
*.tlog
|
*.tlog
|
||||||
*.log
|
*.log
|
||||||
*.vcxproj
|
|
||||||
*.filters
|
|
||||||
Project2.vcxproj.filters
|
|
||||||
*.filters
|
|
||||||
*.vcxproj
|
|
||||||
Project2.vcxproj
|
|
||||||
Project2.vcxproj.filters
|
|
||||||
main.c
|
|
||||||
|
51
Makefile
51
Makefile
@ -1,51 +0,0 @@
|
|||||||
# 定义编译器
|
|
||||||
CC = gcc
|
|
||||||
|
|
||||||
# 定义源文件目录
|
|
||||||
SRC_DIR = .
|
|
||||||
|
|
||||||
# 定义头文件目录
|
|
||||||
INC_DIR = .
|
|
||||||
|
|
||||||
# 定义目标文件目录
|
|
||||||
OBJ_DIR = obj
|
|
||||||
|
|
||||||
# 定义可执行文件名称
|
|
||||||
TARGET = main
|
|
||||||
|
|
||||||
# 定义源文件后缀
|
|
||||||
SRC_EXT = .c
|
|
||||||
|
|
||||||
# 定义目标文件后缀
|
|
||||||
OBJ_EXT = .o
|
|
||||||
|
|
||||||
# 定义源文件列表
|
|
||||||
SRC_FILES = \
|
|
||||||
array_queue.c \
|
|
||||||
array_stack.c \
|
|
||||||
linked_list_stack.c \
|
|
||||||
linked_list.c \
|
|
||||||
sq_list.c \
|
|
||||||
main.c
|
|
||||||
|
|
||||||
# 使用正则表达式替换源文件后缀为.o,生成目标文件列表
|
|
||||||
OBJ_FILES = $(patsubst $(SRC_DIR)/%$(SRC_EXT), $(OBJ_DIR)/%$(OBJ_EXT), $(SRC_FILES))
|
|
||||||
|
|
||||||
# 定义编译选项
|
|
||||||
CFLAGS = -I$(INC_DIR) -Wall -Wextra -pedantic
|
|
||||||
|
|
||||||
# 默认目标,调用链接规则
|
|
||||||
all: $(TARGET)
|
|
||||||
|
|
||||||
# 链接规则,将所有目标文件链接成可执行文件
|
|
||||||
$(TARGET): $(OBJ_FILES)
|
|
||||||
$(CC) $(CFLAGS) $^ -o $@
|
|
||||||
|
|
||||||
# 编译规则,将源文件编译成目标文件
|
|
||||||
$(OBJ_DIR)/%$(OBJ_EXT): $(SRC_DIR)/%$(SRC_EXT)
|
|
||||||
@mkdir -p $(OBJ_DIR)
|
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
# 清理目标文件和可执行文件
|
|
||||||
clean:
|
|
||||||
rm -rf $(OBJ_DIR) $(TARGET)
|
|
@ -21,20 +21,16 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="array_queue.c" />
|
<ClCompile Include="array_queue.c" />
|
||||||
<ClCompile Include="array_stack.c" />
|
<ClCompile Include="array_stack.c" />
|
||||||
<ClCompile Include="binary_tree.c" />
|
|
||||||
<ClCompile Include="linked_list.c" />
|
<ClCompile Include="linked_list.c" />
|
||||||
<ClCompile Include="linked_list_stack.c" />
|
<ClCompile Include="linked_list_stack.c" />
|
||||||
<ClCompile Include="linked_queue.c" />
|
|
||||||
<ClCompile Include="main.c" />
|
<ClCompile Include="main.c" />
|
||||||
<ClCompile Include="sq_list.c" />
|
<ClCompile Include="sq_list.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="array_queue.h" />
|
<ClInclude Include="array_queue.h" />
|
||||||
<ClInclude Include="array_stack.h" />
|
<ClInclude Include="array_stack.h" />
|
||||||
<ClInclude Include="binary_tree.h" />
|
|
||||||
<ClInclude Include="linked_list.h" />
|
<ClInclude Include="linked_list.h" />
|
||||||
<ClInclude Include="linked_list_stack.h" />
|
<ClInclude Include="linked_list_stack.h" />
|
||||||
<ClInclude Include="linked_queue.h" />
|
|
||||||
<ClInclude Include="sq_list.h" />
|
<ClInclude Include="sq_list.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
|
@ -33,12 +33,6 @@
|
|||||||
<ClCompile Include="sq_list.c">
|
<ClCompile Include="sq_list.c">
|
||||||
<Filter>源文件</Filter>
|
<Filter>源文件</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="linked_queue.c">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="binary_tree.c">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="sq_list.h">
|
<ClInclude Include="sq_list.h">
|
||||||
@ -56,11 +50,5 @@
|
|||||||
<ClInclude Include="array_queue.h">
|
<ClInclude Include="array_queue.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="linked_queue.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="binary_tree.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,61 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "binary_tree.h"
|
|
||||||
|
|
||||||
tree_node *init_binary_tree(elem_type value)
|
|
||||||
{
|
|
||||||
tree_node *node = (tree_node *)malloc(sizeof(tree_node));
|
|
||||||
if (node == NULL)
|
|
||||||
{
|
|
||||||
printf("error: malloc failed from:init_binary_tree\n");
|
|
||||||
}
|
|
||||||
node->value = value;
|
|
||||||
node->left = NULL;
|
|
||||||
node->right = NULL;
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 插入节点
|
|
||||||
void insert_tree_node(tree_node *node,tree_node *node_new)
|
|
||||||
{
|
|
||||||
if (node == NULL)
|
|
||||||
{
|
|
||||||
node ->left = node_new;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tree_node *temp = node;
|
|
||||||
node ->left = node_new;
|
|
||||||
|
|
||||||
}
|
|
||||||
// 删除节点
|
|
||||||
|
|
||||||
// 遍历树节点 bfs
|
|
||||||
void traverse_tree(tree_node *roots)
|
|
||||||
{
|
|
||||||
tree_node *queue[3] = {NULL,NULL,NULL};
|
|
||||||
int front = 0;
|
|
||||||
int rear = 0;
|
|
||||||
if (roots == NULL)
|
|
||||||
{
|
|
||||||
printf("error: roots is NULL\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf("%d\n", roots->value);
|
|
||||||
while(roots ->left != NULL && roots -> right != NULL)
|
|
||||||
{
|
|
||||||
tree_node *temp[2] = {roots->left,roots->right};
|
|
||||||
for (int i = 0;i<2;i++)
|
|
||||||
{
|
|
||||||
if (temp[i] != NULL)
|
|
||||||
{
|
|
||||||
queue[rear] = temp[i];
|
|
||||||
rear = (rear + 1) % 3;
|
|
||||||
printf("%d ",temp[i]->value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
roots = queue[front];
|
|
||||||
front = (front+1) % 3;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
#ifndef BINARY_TREE
|
|
||||||
#define BINARY_TREE
|
|
||||||
#define elem_type int
|
|
||||||
typedef struct tree_node
|
|
||||||
{
|
|
||||||
elem_type value;
|
|
||||||
struct tree_node *left;
|
|
||||||
struct tree_node *right;
|
|
||||||
}tree_node;
|
|
||||||
// 初始化树节点
|
|
||||||
tree_node *init_binary_tree(elem_type value);
|
|
||||||
// 插入节点
|
|
||||||
void insert_tree_node(tree_node *node,tree_node *node_new);
|
|
||||||
// 删除节点
|
|
||||||
void delete_node(tree_node *node);
|
|
||||||
// 遍历树节点
|
|
||||||
void traverse_tree(tree_node *roots);
|
|
||||||
#endif // DEBUG
|
|
@ -73,14 +73,11 @@ address_node *find_node(node* head, elem_type value)
|
|||||||
void print_node_list(node* head)
|
void print_node_list(node* head)
|
||||||
{
|
{
|
||||||
node* head_1 = head;
|
node* head_1 = head;
|
||||||
//printf("[%d ",head_1->value);
|
printf("[%d ",head_1->value);
|
||||||
printf("[");
|
while (head_1->next != NULL)
|
||||||
while (1)
|
|
||||||
{
|
{
|
||||||
printf("%d ", head_1->value);
|
|
||||||
head_1 = head_1->next;
|
head_1 = head_1->next;
|
||||||
if (head_1 == NULL)
|
printf("%d ", head_1->value);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
printf("]\n");
|
printf("]\n");
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "linked_list_stack.h"
|
#include "linked_list_stack.h"
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ʼջ
|
// 初始栈
|
||||||
stack_linked* init_stack_linked(void)
|
stack_linked* init_stack_linked(void)
|
||||||
{
|
{
|
||||||
stack_linked* s = (stack_linked*)malloc(sizeof(stack_linked));
|
stack_linked* s = (stack_linked*)malloc(sizeof(stack_linked));
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
{
|
{
|
||||||
printf("<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
printf("内存分配失败!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
s->top = NULL;
|
s->top = NULL;
|
||||||
@ -16,13 +16,13 @@ stack_linked* init_stack_linked(void)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ջ
|
// 入栈
|
||||||
void push_stack_linked(stack_linked* s, elem_type value)
|
void push_stack_linked(stack_linked* s, elem_type value)
|
||||||
{
|
{
|
||||||
stack_node* node = (stack_node*)malloc(sizeof(stack_node));
|
stack_node* node = (stack_node*)malloc(sizeof(stack_node));
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
{
|
{
|
||||||
printf("<EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n");
|
printf("内存分配失败!\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
node->value = value;
|
node->value = value;
|
||||||
@ -31,7 +31,7 @@ void push_stack_linked(stack_linked* s, elem_type value)
|
|||||||
s->size++;
|
s->size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ջ
|
// 出栈
|
||||||
int pop_stack_linked(stack_linked* s)
|
int pop_stack_linked(stack_linked* s)
|
||||||
{
|
{
|
||||||
int flog = 0;
|
int flog = 0;
|
||||||
|
@ -1,91 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "linked_queue.h"
|
|
||||||
|
|
||||||
link_queue* init_link_queue()
|
|
||||||
{
|
|
||||||
link_queue* q = (link_queue*)malloc(sizeof(link_queue));
|
|
||||||
if (q == NULL)
|
|
||||||
{
|
|
||||||
printf("error: malloc from init_link_queue failed\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
q->front = NULL;
|
|
||||||
q->rear = NULL;
|
|
||||||
q->size = 0;
|
|
||||||
return q;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Èë¶Ó
|
|
||||||
void push_link_queue(link_queue* q, elem_type value)
|
|
||||||
{
|
|
||||||
node* new_node = (node*)malloc(sizeof(node));
|
|
||||||
if (new_node == NULL)
|
|
||||||
{
|
|
||||||
printf("error: malloc from push_link_queue failed\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
new_node->value = value;
|
|
||||||
new_node->next = NULL;
|
|
||||||
if (q->front == NULL)
|
|
||||||
{
|
|
||||||
q->front = new_node;
|
|
||||||
q->rear = new_node;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
q->rear->next = new_node;
|
|
||||||
q->rear = new_node;
|
|
||||||
}
|
|
||||||
q->size++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ³ö¶Ó
|
|
||||||
elem_type pop_link_queue(link_queue* q)
|
|
||||||
{
|
|
||||||
if (empty_link_queue(q))
|
|
||||||
{
|
|
||||||
printf("error: pop from empty link_queue\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
link_queue* tmp = q->front;
|
|
||||||
elem_type a = q->front->value;
|
|
||||||
q->front = q->front->next;
|
|
||||||
q->size--;
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ÅпÕ
|
|
||||||
int empty_link_queue(link_queue* q)
|
|
||||||
{
|
|
||||||
if (q->size == 0)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ´òÓ¡
|
|
||||||
int print_link_queue(link_queue* q)
|
|
||||||
{
|
|
||||||
if (empty_link_queue(q))
|
|
||||||
{
|
|
||||||
printf("error: queue empty form: print_link_queue\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
node* head = q->front;
|
|
||||||
printf("[");
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
printf(" %d ", head->value);
|
|
||||||
head = head->next;
|
|
||||||
if (head == NULL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("]\n");
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
#ifndef LINKED_QUEUE_H
|
|
||||||
#define LINKED_QUEUE_H
|
|
||||||
#define elem_type int
|
|
||||||
|
|
||||||
typedef struct node
|
|
||||||
{
|
|
||||||
elem_type value;
|
|
||||||
struct node* next;
|
|
||||||
} node;
|
|
||||||
|
|
||||||
typedef struct linked_queue
|
|
||||||
{
|
|
||||||
struct node* front;
|
|
||||||
struct node* rear;
|
|
||||||
int size;
|
|
||||||
}link_queue;
|
|
||||||
|
|
||||||
// 初始化
|
|
||||||
link_queue* init_link_queue();
|
|
||||||
|
|
||||||
// 入队
|
|
||||||
void push_link_queue(link_queue* q, elem_type value);
|
|
||||||
|
|
||||||
// 出队
|
|
||||||
elem_type pop_link_queue(link_queue* q);
|
|
||||||
|
|
||||||
// 判空
|
|
||||||
int empty_link_queue(link_queue* q);
|
|
||||||
|
|
||||||
// 打印
|
|
||||||
int print_link_queue(link_queue* q);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
185
main.c
185
main.c
@ -1,87 +1,93 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "binary_tree.h"
|
|
||||||
int main(void) {
|
|
||||||
|
|
||||||
// sq_list* L = init_sq_list();
|
int main(void)
|
||||||
// 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);*/
|
|
||||||
|
|
||||||
/* array_stack* stack = init_array_stack();
|
//sq_list* L = init_sq_list();
|
||||||
push_array_stack(stack, 1);
|
//sq_list* N = init_sq_list();
|
||||||
push_array_stack(stack, 2);
|
//for (int i = 1; i <= 3; i++)
|
||||||
push_array_stack(stack, 3);*/
|
//{
|
||||||
|
// 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);*/
|
||||||
|
|
||||||
/* array_queue *q = init_array_queue();
|
|
||||||
push_array_queue(q,0);
|
/* array_stack* stack = init_array_stack();
|
||||||
push_array_queue(q,1);
|
push_array_stack(stack, 1);
|
||||||
push_array_queue(q,2);
|
push_array_stack(stack, 2);
|
||||||
print_array_queue(q);
|
push_array_stack(stack, 3);*/
|
||||||
printf("---------------------\n");
|
|
||||||
pop_array_queue(q);
|
|
||||||
print_array_queue(q);
|
|
||||||
printf("----------\n");
|
|
||||||
push_array_queue(q, 666);
|
|
||||||
print_array_queue(q);*/
|
|
||||||
|
|
||||||
// node* q1 = init_node(1);
|
|
||||||
// node* q2 = init_node(2);
|
|
||||||
// node* q3 = init_node(3);
|
|
||||||
// node* q4 = init_node(4);
|
|
||||||
// q1->next = q2;
|
|
||||||
// q2->next = q3;
|
|
||||||
// q3->next = q4;
|
|
||||||
////address_node *n = find_node(q1, 3);
|
|
||||||
//// printf("%d\n %p\n", n->n,n->p
|
|
||||||
////int e = get_node_list(q1);
|
|
||||||
// node* q2_3 = init_node(0);
|
|
||||||
// insert_node(q2, q2_3);
|
|
||||||
// print_node_list(q1);
|
|
||||||
// delete_node(q2);
|
|
||||||
// print_node_list(q1);
|
|
||||||
|
|
||||||
/* stack_linked* head = init_stack_linked();
|
|
||||||
push_stack_linked(head, 1);
|
/* array_queue *q = init_array_queue();
|
||||||
push_stack_linked(head, 2);
|
push_array_queue(q,0);
|
||||||
push_stack_linked(head, 3);
|
push_array_queue(q,1);
|
||||||
print_linked(head);
|
push_array_queue(q,2);
|
||||||
pop_stack_linked(head);
|
print_array_queue(q);
|
||||||
print_linked(head);*/
|
printf("---------------------\n");
|
||||||
|
pop_array_queue(q);
|
||||||
|
print_array_queue(q);
|
||||||
|
printf("----------\n");
|
||||||
|
push_array_queue(q, 666);
|
||||||
|
print_array_queue(q);*/
|
||||||
|
|
||||||
|
// node* q1 = init_node(1);
|
||||||
|
// node* q2 = init_node(2);
|
||||||
|
// node* q3 = init_node(3);
|
||||||
|
// node* q4 = init_node(4);
|
||||||
|
// q1->next = q2;
|
||||||
|
// q2->next = q3;
|
||||||
|
// q3->next = q4;
|
||||||
|
// //address_node *n = find_node(q1, 3);
|
||||||
|
// // printf("%d\n %p\n", n->n,n->p
|
||||||
|
// //int e = get_node_list(q1);
|
||||||
|
// node* q2_3 = init_node(0);
|
||||||
|
// insert_node(q2, q2_3);
|
||||||
|
// print_node_list(q1);
|
||||||
|
// delete_node(q2);
|
||||||
|
// print_node_list(q1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
stack_linked* head = init_stack_linked();
|
||||||
|
push_stack_linked(head, 1);
|
||||||
|
push_stack_linked(head, 2);
|
||||||
|
push_stack_linked(head, 3);
|
||||||
|
print_linked(head);
|
||||||
|
pop_stack_linked(head);
|
||||||
|
print_linked(head);
|
||||||
|
*/
|
||||||
|
|
||||||
// queue_test();
|
// queue_test();
|
||||||
/*array_queue *q = init_array_queue();
|
array_queue *q = init_array_queue();
|
||||||
push_array_queue(q, 1);
|
push_array_queue(q, 1);
|
||||||
push_array_queue(q, 2);
|
push_array_queue(q, 2);
|
||||||
push_array_queue(q, 3);
|
push_array_queue(q, 3);
|
||||||
@ -91,31 +97,8 @@ int main(void) {
|
|||||||
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);
|
||||||
/* link_queue* q = init_link_queue();
|
printf("Hello World!\n");
|
||||||
push_link_queue(q, 1);
|
system("pause");
|
||||||
push_link_queue(q, 2);
|
return 0;
|
||||||
push_link_queue(q, 3);
|
|
||||||
print_link_queue(q);
|
|
||||||
printf("____________________\n");
|
|
||||||
pop_link_queue(q);
|
|
||||||
print_link_queue(q);*/
|
|
||||||
|
|
||||||
tree_node *root = init_binary_tree(1);
|
|
||||||
tree_node *node1 = init_binary_tree(2);
|
|
||||||
tree_node *node2 = init_binary_tree(3);
|
|
||||||
tree_node *node3 = init_binary_tree(4);
|
|
||||||
tree_node *node4 = init_binary_tree(5);
|
|
||||||
tree_node *node5 = init_binary_tree(6);
|
|
||||||
tree_node *node6 = init_binary_tree(7);
|
|
||||||
root->left = node1;
|
|
||||||
root->right = node2;
|
|
||||||
node1->left = node3;
|
|
||||||
node1->right = node4;
|
|
||||||
node2->left = node5;
|
|
||||||
node2->right = node6;
|
|
||||||
traverse_tree(root);
|
|
||||||
printf("Hello World!\n");
|
|
||||||
system("pause");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user