Planificación médica de Xining
# include & ltstdlib.h & gt
# include & ltmalloc.h & gt
#Definición ¿OK? 1
#¿Error de definición? 0
#¿Definir desbordamiento? 0
typedef char TElemType
typedef int status;
nodo de bits de estructura typedef
{
datos de telemetría ;
struct BiTNode *lchild, *rchild
}BiTNode, *BiTree
typedef enum {Enlace, Hilo} PointerTag
typedef estructura BiThrNode
{
Datos de telemetría;
estructura BiThrNode *lchild, *rchild
Etiqueta de puntero LTag, RTag
} BiThrNode
typedef BiThrNode * BiThrTree
BiTree CreateBiTree(BiTree T)? //El recorrido de primer orden construye un árbol binario
{
char ch
scanf("%c ", & ampch);
si (ch=='# ')? //# representa un puntero nulo.
T = NULL
Otro
{
t =(nodo de bits *)malloc(tamaño de(nodo de bits));? //nodo de aplicación
if (!t)
salir(overflow);
t->data = ch? //Generar nodo raíz
t->;l child = crear bitree(T->l child);? //Construir el subárbol izquierdo
t->rchild = create bitree(T->rchild);? //Construye el subárbol de la derecha
}
return T;
}
Status InOrderTraverse(BiTree T, Status(* visit )(teletipo))
{//Recorrido en orden de un árbol binario
If (T)
{
if(en orden atravesar(T->lchild, acceso))
if (acceso(T->datos))
if(en orden atravesar(T-> niño, visita))
Regresar OK;
Regresar error;
}
Otros
Regresar OK ;
}
Elemento de impresión de estado (tipo remoto e)
{
printf("%-2c ", e);
Regresar OK;
}
void main()
{
BiTree T = NULL p >
Printf("Ingrese la secuencia de caracteres para construir el árbol binario:");
T = crear bitree(T);
If (T) p>
Printf("¡La construcción del árbol binario fue exitosa! \ n ");
Otros
Printf("¡¡¡La construcción del árbol binario falló!!!\ n "); /p>
Printf ("Recorrido en orden de un árbol binario:");
InOrderTraverse(T, elemento de impresión);
printf(" \ n ");
}
}
p>