标签:顺序 span str define div return pre style print
#include<stdio.h> #include<stdlib.h> #define maxsize 127 typedef char TElemType; typedef struct node{ TElemType data[maxsize]; TElemType n; }SqBTree; void createBTree(SqBTree&T,TElemType pre[],int n,int &m){ TElemType ch=pre[m++]; if(ch==‘;‘)return; if(ch!=‘#‘){ T.data[n]=ch; createBTree(T,pre,n*2+1,m); createBTree(T,pre,n*2+2,m); } } void CreatEmptyBTree(SqBTree &T){ for(int i = 0;i<maxsize;i++){ T.data[i] = ‘#‘; } } void PrintBTree(SqBTree&t,int n){ if(t.data[n]!=‘#‘){ printf("%c",t.data[n]); printf("("); PrintBTree(t,n*2+1); printf(","); PrintBTree(t,n*2+1); printf(")"); } } int main(){ SqBTree BT; int n=0; int m=0; char ch[]={‘A‘,‘B‘,‘C‘,‘#‘,‘#‘,‘D‘,‘E‘,‘#‘,‘#‘,‘#‘,‘;‘}; CreatEmptyBTree(BT); createBTree(BT,ch,n,m); PrintBTree(BT,n); }
标签:顺序 span str define div return pre style print
原文地址:https://www.cnblogs.com/YShen0/p/10972750.html