1.二叉树的顺序存储
2.二叉树的链接存储
①.二叉链表的存储
②三叉链表的存储
二叉链表法建立二叉树
#include <stdio.h>
#include <bits/stdc++.h>
#define maxsize 10
//#define NULL 0
using namespace std;
typedef struct node
{
char data;
struct node *lchild,*rchild;
}Bitree;
Bitree *Q[maxsize];
void creatBitree()
{
char ch;
int front ,rear;
Bitree *T,*s;
front =1;
rear=0;
ch=getchar();
while(ch!='#')
{
s=NULL;
if(ch!='@')
{
s=(Bitree *)malloc (sizeof(Bitree));
s->data=ch;
s->lchild=s->rchild=NULL;
}
rear++;
Q[rear]=s;
if(rear==1)
{
T=s;
}
else
{
if(s!=NULL&&Q[front]!=NULL)
{
if(rear%2==0)
{
Q[front]->lchild=s;
}
else Q[front]->rchild=s;
if(rear%2==1) front++;
}
}
ch=getchar();
}
// return T;
}
int main()
{
creatBitree();
system("pause");
return 0;
}