2003

Grusel++ of the month

Home
Download Source
/******************************************************************************/
/*                                                                            */
/*                                                              FILE: may.cpp */
/*                                                                            */
/*  Try to draw the 'tree' data structure                                     */
/*  =====================================                                     */
/*                                                                            */
/*  Compiled and tested with Visual C++ 6.0                                   */
/*                                                                            */
/*  V1.00   31-MAY-2003   P. Tellenbach   http://www.heimetli.ch/             */
/*                                                                            */
/******************************************************************************/

#include <iostream>

struct Node
{
   char  ch ;
   Node *left ;
   Node *right ;
} tree[] = {
   { 'H',  tree + 2, tree +  4 },
   { 'l',  NULL,     NULL      },
   { 'e',  tree + 1, tree +  1 },
   { 'o',  NULL,     NULL      },
   { 'o',  tree + 7, tree +  6 },
   { 'r',  tree + 1, tree +  8 },
   { 'w',  tree + 3, tree +  5 },
   { ' ',  NULL,     NULL      },
   { 'd',  tree + 7, tree + 10 },
   { '\n', NULL,     NULL      },
   { '!',  NULL,     tree +  9 }
} ;

void traverse( Node *pn )
{
   if( pn )
   {
      std::cout << pn->ch ;

      traverse( pn->left  ) ;
      traverse( pn->right ) ;
   }
}

int main()
{
   traverse( tree ) ;

   return 0 ;
}