二叉树
typedef struct Tree{
int data;
struct Tree * lTree;
struct Tree * rTree;
}TREE,* PTREE;
void creatTree(struct Tree * * tre,int value){
if (tre==nil) {
(* tre) = malloc(sizeof(TREE));
(* tre)->lTree = nil;
(* tre)->rTree = nil;
(* tre)->data = value;
}else{
if ((* tre)->data > value) {
creatTree((* tre)->rTree,value);
}else{
creatTree((* tre)->lTree, value);
}
}
}
栈分顺序栈和链式栈
1,顺序栈
typedef struct Stack{
int data[100];
int top;
}STACK,* PSTACK;
void creatStack(struct Stack * * st)
{
(* st) = malloc(sizeof(STACK));
(* st)->top = -1;
}
2,链式栈
typedef struct LinkStack{
int data;
struct LinkStack * next;
}LINKSTACK,* PLINKSTACK;
void creatLinkStack(struct LinkStack * * st)
{
(* st) = malloc(sizeof(LINKSTACK));
(* st)->next = nil;
}