同样的代码为什么我的会报错
#include<iostream>usingnamespacestd;#defineMAXSIZE100#defineOK1;typedefintKeyType;typ...
#include<iostream>using namespace std;#define MAXSIZE 100#define OK 1;typedef int KeyType; typedef struct{ KeyType key;} ElemType;typedef struct BSTNode{ ElemType data; struct BSTNode *lchild,*rchild;}BSTNode,*BSTree;BSTree SearchBST(BSTree T,KeyType key){ if((!T)||key==T->data.key) return T; else if (key<T->data.key) return SearchBST(T->lchild,key); else return SearchBST(T->rchild,key);}void InsertBST(BSTree &T,ElemType e){ if(!T) { BSTree S; S->data=e; S->lchild=S->rchild=NULL; T=S; } else if(e.key<T->data.key) InsertBST(T->lchild,e); else if(e.key<T->data.key) InsertBST(T->rchild,e);}void CreateBST(BSTree &T){ ElemType e; T=NULL; cout<<"输入二叉顺序树的根节点"<<endl; cin>>e; while(e.key!=0) { InserstBSN(T,e); cout<<"输入结点(输入0结束)"; cin>>e; }}int main(){ BSTree FTW; CreatBST(FTW); int key=24; SearchBST(FTW,key); return 0;}
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询