2001

Grusel++ of the month

Home
Download Source
/******************************************************************************/
/*                                                                            */
/*                                                             FILE: july.cpp */
/*                                                                            */
/*  A binary tree and binary operators produce a well known constant          */
/*  ================================================================          */
/*                                                                            */
/*  Compiled and tested with Visual C++ V6.0                                  */
/*                                                                            */
/*  V1.00   21-JUL-2001   P. Tellenbach   http://www.heimetli.ch/             */
/*                                                                            */
/******************************************************************************/

#include <iostream>

struct node
{
  node *zero ;
  node *one  ;
  char  ch ;
} nodes[] =
{ { nodes + 2,  nodes + 6,  '-' }, { 0, 0, 'o' },
  { nodes + 18, nodes + 4,  '-' }, { 0, 0, '!' },
  { nodes + 1,  nodes + 3,  '-' }, { 0, 0, ' ' },
  { nodes + 8,  nodes + 12, '-' }, { 0, 0, 'd' },
  { nodes + 5,  nodes + 10, '-' }, { 0, 0, 'H' },
  { nodes + 9,  nodes + 7,  '-' }, { 0, 0, 'W' },
  { nodes + 14, nodes + 16, '-' }, { 0, 0, 'r' },
  { nodes + 17, nodes + 11, '-' }, { 0, 0, '\0'},
  { nodes + 13, nodes + 15, '-' }, { 0, 0, 'e' },
                                   { 0, 0, 'l' } } ;

int main()
{
  char *pm = "\xAC\x05\x35\x71\x71\xF8" ;
  int  msk = 0x80 ;

  for( node *pn = nodes; ; pn = nodes )
  {
     while( pn->ch == '-' )
     {
        pn = *pm & msk ? pn->one : pn->zero ;

        if( (msk >>= 1) == 0 )
        {
           pm++ ;
           msk = 0x80 ;
        }
     }

     if( pn->ch == '\0' )
        return !(std::cout << std::endl) ;

     std::cout << pn->ch ;
  }
}