write.c
来自「Trees are natural structures for represe」· C语言 代码 · 共 28 行
C
28 行
#include <stdio.h>#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. */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?