(第一次发布海报,而不是新编程,请耐心等待!)
我对打印格式化二叉树(在CLI环境中)和C实现的高效通用算法感兴趣.这是我为了好玩而编写的一些代码(这是原始版本的简化版本,是支持许多BST操作的大型程序的一部分,但它应该编译得很好):
#include <stdbool.h> // C99, boolean type support
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define DATATYPE_IS_DOUBLE
#define NDEBUG // disable assertions
#include <assert.h>
#define WCHARBUF_LINES 20 // def: 20
#define WCHARBUF_COLMS 800 // def: 80 (using a huge number, like 500, is a good idea,
// in order to prevent a buffer overflow :)
#define RECOMMENDED_CONS_WIDTH 150
#define RECOMMENDED_CONS_WIDTHQ "150" // use the same value, quoted
/* Preprocessor directives depending on DATATYPE_IS_* : */
#if …Run Code Online (Sandbox Code Playgroud)