#include #include "Tree.h" void WriteTreeSlave( Tree T, int indent ) /*L.Allison*/ /* Write a tree, with root at the LHS, by a right-to-left, infix traversal */ { int i; char str[]="----------|"; if( T != NULL ) { WriteTreeSlave(T->right, indent+1); for(i=0; i < indent; i++) printf(" |"); sprintf(str, "%s", T->elt); /* NB. assumed to be a Tree of String */ i = 0; while( str[i] != NULL ) i++; if( i > 0 && i < 10 && str[i-1] == '-' ) { str[i]=' '; i++; } /* let '-' signs stand out */ while( i < 10 ) { str[i]='-'; i++; } str[i] = '|'; str[i+1] = NULL; printf("%s\n", str); WriteTreeSlave(T->left, indent+1); } }/*WriteTreeSlave*/ void WriteTree( Tree T ) { WriteTreeSlave(T, 0); } /* Write a Tree down the page. */