//先序遍历
void preorder_tree(tree_p T){
if(T==NULL){
printf("XXX\n");
}
printf("%c ",T->data);
preorder_tree(T->lchild);
preorder_tree(T->rchild)
}
//中序遍历
void preorder_tree(tree_p T){
if(T==NULL){
printf("XXX\n");
}
preorder_tree(T->lchild);
printf("%c ",T->data);
preorder_tree(T->rchild);
}
//后序遍历
void preorder_tree(tree_p T){
if(T==NULL){
printf("XXX\n");
}
preorder_tree(T->rchild);
preorder_tree(T->lchild);
printf("%c ",T->data);
}
乱七八糟的 link_queue.c
#include "link_queue.h"
queue_p create_head(){
queue_p Q=(queue_p)malloc(sizeof(queue));
if(Q=NULL){
printf("创建失败\n");
return NULL'
}
Q->rear=Q->front=1;
return Q;
}
queue_p create_node(datatpye data){
queue_p new=(queue_p)malloc(sizeof(queue));
if(new==NULL){
printf("创建失败\n");
return NULL;
}
new->data=data;
return new;
}
//入队
void push_queue(queue_p,datatpye data){
if(Q==NULL){
printf("真烦人\n");
}
queue_p new=create_node(data);
Q->rear=new;
Q->rear=Q->rear->next;
}
//出队
void pop_queue(queue_p Q){
if(Q=NULL){
printf("要吐了\n");
return;
}
printf("%c",Q->data[front]);
Q->front=Q->front->next;
}
//销毁
void del_queue(queue_p Q){
if(Q==NULL){
printf("不想干了\n");
return;
}
while(Q->rear!=Q->front){
free(Q->front)
Q->front=Q->front->next;
}
}
乱七八糟的 link_queue.h
#ifndef __LINK_QUEUE_H__
#define __LINK_QUEUE_H__
#include <stdio.h>
#include <stdlib.h>
typedef int datatpye
typedef struct Q_link(){
datatpye data;
struct Q_link *next;
}queue,*queue_p;
typedef struct link_queue{
queue_p rear;
queue_p front;
}link_queue;
#endif
先a,b,c,d,e,f,g,h, 先a,b,c,d,e,f,g,h,l
后b,d,c,e,a,f,h,g, 后a,c,e,d,b,h,i,g,f