欢迎来到天天文库
浏览记录
ID:54742602
大小:16.41 KB
页数:9页
时间:2020-04-21
《医院设施管理系统C++类树.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、C++类树医院设施管理树的应用,统计任意两个结点之间的结点个数,支出给定结点的子结点,浏览整个医院的结构,C++,类,树,医院设施管理,C++,类#include#include#include#include#include#includeusingnamespacestd;classhosnode{public:stringname;intnum;hosnode(stringn=NULL,intnumber=0);stringName();int
2、Num();friendostream&operator<<(ostream&out,hosnode&node);};hosnode::hosnode(stringn,intnumber){name=n;num=number;}stringhosnode::Name(){returnname;}inthosnode::Num(){returnnum;}ostream&operator<<(ostream&out,hosnode&node){out<<""<<"
3、"<4、name<<"5、"<6、";returnout;}classtreenode{//treenode*parent;//父结点public:hosnodevalue;treenode*pc;//最左边子结点treenode*ls;//左兄弟节点treenode*rs;//右兄弟节点treenode(hosnodem_value);/*voidsetvalue(hosnodem_value);voidsetchild(treenode*pointer);v7、oidsetsibling(treenode*pointer);voidinsertfirst(treenode*node);voidinsertnext(treenode*node);voidprint();*/voidvisit();};treenode::treenode(hosnodem_value):value(m_value){pc=NULL;ls=NULL;rs=NULL;}voidtreenode::visit(){cout<8、node*getroot();treenode*Parent(treenode*cur);//查找cur的父结点treenode*find(stringcur);//查找医院相关部门curvoidinsert(stringparent,hosnode*value);//结点的插入函数(通过不断地插入操作构建医院结构树)voidrootfirst(treenode*root);//先根深度遍历voidrootlast(treenode*root);//后根深度遍历voidwith(treenode*root);//广度优先遍历intcount(strin9、ggparent,stringchild);//父结点包含子结点个数的统计voids_treatment();//模拟处理函数voidinterface1();//操作界面voidshow(stringn);//浏览输出函数};tree::tree(){root=NULL;}treenode*tree::getroot(){returnroot;}voidtree::insert(stringparent,hosnode*value){hosnode*tmp;treenode*tmp1,*tmp2,*tmp3;if(root==NULL){tmp=ne10、whosnode(parent,1);tmp2=newtreenode(*value);root=newtreenode(*tmp);root->pc=tmp2;}else{tmp1=find(parent);if(tmp1){tmp2=newtreenode(*value);if(tmp1->pc==NULL){tmp1->pc=tmp2;}else{tmp3=tmp1->pc;while(tmp3->ls){tmp3=tmp3->ls;}tmp3->ls=tmp2;}}}}treenode*tree::Parent(treenode*cur){if11、(!cur)returnNULL;else{treenode*pointer=root,*tm
4、name<<"
5、"<6、";returnout;}classtreenode{//treenode*parent;//父结点public:hosnodevalue;treenode*pc;//最左边子结点treenode*ls;//左兄弟节点treenode*rs;//右兄弟节点treenode(hosnodem_value);/*voidsetvalue(hosnodem_value);voidsetchild(treenode*pointer);v7、oidsetsibling(treenode*pointer);voidinsertfirst(treenode*node);voidinsertnext(treenode*node);voidprint();*/voidvisit();};treenode::treenode(hosnodem_value):value(m_value){pc=NULL;ls=NULL;rs=NULL;}voidtreenode::visit(){cout<8、node*getroot();treenode*Parent(treenode*cur);//查找cur的父结点treenode*find(stringcur);//查找医院相关部门curvoidinsert(stringparent,hosnode*value);//结点的插入函数(通过不断地插入操作构建医院结构树)voidrootfirst(treenode*root);//先根深度遍历voidrootlast(treenode*root);//后根深度遍历voidwith(treenode*root);//广度优先遍历intcount(strin9、ggparent,stringchild);//父结点包含子结点个数的统计voids_treatment();//模拟处理函数voidinterface1();//操作界面voidshow(stringn);//浏览输出函数};tree::tree(){root=NULL;}treenode*tree::getroot(){returnroot;}voidtree::insert(stringparent,hosnode*value){hosnode*tmp;treenode*tmp1,*tmp2,*tmp3;if(root==NULL){tmp=ne10、whosnode(parent,1);tmp2=newtreenode(*value);root=newtreenode(*tmp);root->pc=tmp2;}else{tmp1=find(parent);if(tmp1){tmp2=newtreenode(*value);if(tmp1->pc==NULL){tmp1->pc=tmp2;}else{tmp3=tmp1->pc;while(tmp3->ls){tmp3=tmp3->ls;}tmp3->ls=tmp2;}}}}treenode*tree::Parent(treenode*cur){if11、(!cur)returnNULL;else{treenode*pointer=root,*tm
6、";returnout;}classtreenode{//treenode*parent;//父结点public:hosnodevalue;treenode*pc;//最左边子结点treenode*ls;//左兄弟节点treenode*rs;//右兄弟节点treenode(hosnodem_value);/*voidsetvalue(hosnodem_value);voidsetchild(treenode*pointer);v
7、oidsetsibling(treenode*pointer);voidinsertfirst(treenode*node);voidinsertnext(treenode*node);voidprint();*/voidvisit();};treenode::treenode(hosnodem_value):value(m_value){pc=NULL;ls=NULL;rs=NULL;}voidtreenode::visit(){cout<8、node*getroot();treenode*Parent(treenode*cur);//查找cur的父结点treenode*find(stringcur);//查找医院相关部门curvoidinsert(stringparent,hosnode*value);//结点的插入函数(通过不断地插入操作构建医院结构树)voidrootfirst(treenode*root);//先根深度遍历voidrootlast(treenode*root);//后根深度遍历voidwith(treenode*root);//广度优先遍历intcount(strin9、ggparent,stringchild);//父结点包含子结点个数的统计voids_treatment();//模拟处理函数voidinterface1();//操作界面voidshow(stringn);//浏览输出函数};tree::tree(){root=NULL;}treenode*tree::getroot(){returnroot;}voidtree::insert(stringparent,hosnode*value){hosnode*tmp;treenode*tmp1,*tmp2,*tmp3;if(root==NULL){tmp=ne10、whosnode(parent,1);tmp2=newtreenode(*value);root=newtreenode(*tmp);root->pc=tmp2;}else{tmp1=find(parent);if(tmp1){tmp2=newtreenode(*value);if(tmp1->pc==NULL){tmp1->pc=tmp2;}else{tmp3=tmp1->pc;while(tmp3->ls){tmp3=tmp3->ls;}tmp3->ls=tmp2;}}}}treenode*tree::Parent(treenode*cur){if11、(!cur)returnNULL;else{treenode*pointer=root,*tm
8、node*getroot();treenode*Parent(treenode*cur);//查找cur的父结点treenode*find(stringcur);//查找医院相关部门curvoidinsert(stringparent,hosnode*value);//结点的插入函数(通过不断地插入操作构建医院结构树)voidrootfirst(treenode*root);//先根深度遍历voidrootlast(treenode*root);//后根深度遍历voidwith(treenode*root);//广度优先遍历intcount(strin
9、ggparent,stringchild);//父结点包含子结点个数的统计voids_treatment();//模拟处理函数voidinterface1();//操作界面voidshow(stringn);//浏览输出函数};tree::tree(){root=NULL;}treenode*tree::getroot(){returnroot;}voidtree::insert(stringparent,hosnode*value){hosnode*tmp;treenode*tmp1,*tmp2,*tmp3;if(root==NULL){tmp=ne
10、whosnode(parent,1);tmp2=newtreenode(*value);root=newtreenode(*tmp);root->pc=tmp2;}else{tmp1=find(parent);if(tmp1){tmp2=newtreenode(*value);if(tmp1->pc==NULL){tmp1->pc=tmp2;}else{tmp3=tmp1->pc;while(tmp3->ls){tmp3=tmp3->ls;}tmp3->ls=tmp2;}}}}treenode*tree::Parent(treenode*cur){if
11、(!cur)returnNULL;else{treenode*pointer=root,*tm
此文档下载收益归作者所有