原创 遞歸建立二叉搜索樹

typedef struct Tree { int value; struct Tree *left,*right; }Node,*ptrNode; void CreatBinTree(ptrNode &root,int key)

原创 輸入一個鏈表,從尾到頭打印鏈表每個節點的值

輸入一個鏈表,從尾到頭打印鏈表每個節點的值 typedef struct ptrNode { int value; ptrNode* next; }Node,*ptrLink; ptrLink BinaryCreat(int* a

原创 重建二叉樹

輸入某二叉樹的前序遍歷和中序遍歷的結果,請重建出該二叉樹。假設輸入的前序遍歷和中序遍歷的結果中都不含重複的數字。例如輸入前序遍歷序列{1,2,4,7,3,5,6,8}和中序遍歷序列{4,7,2,1,5,3,8,6},則重建二叉樹並輸出它

原创 漢諾塔

void Hano(char a,char b,char c,int n) { if(n<0) return; if(n==1) printf("move %c to %c\n",a,c); else