2002

Grusel++ of the month

Home
Download Source
/******************************************************************************/
/*                                                                            */
/*                                                             FILE: july.cpp */
/*                                                                            */
/*  An Application For The Partial_Sum Algorithm (AAFTPSA)                    */
/*  ======================================================                    */
/*                                                                            */
/*  Compiled and tested with Visual C++ V6.0                                  */
/*                                                                            */
/*  V1.00   31-JUL-2002   P. Tellenbach   https://www.heimetli.ch/            */
/*                                                                            */
/******************************************************************************/

#include <iostream>
#include <numeric>

using namespace std ;

#define He 'H', 'e' - 'H',
#define ll 'l' - 'e', 0,
#define o  'o' - 'l', ' ' - 'o',
#define wo 'w' - ' ', 'o' - 'w',
#define rl 'r' - 'o', 'l' - 'r',
#define d  'd' - 'l', ' ' - 'd', '!' - ' ', '\n' - '!'

int values[] = { He ll o  wo rl d } ;

int main()
{
  partial_sum( values, values + 14, ostream_iterator<char>(cout) ) ;

  return 0 ;
}

Update 24. July 2022

One more include was necessary to compile the code.

/******************************************************************************/
/*                                                                            */
/*                                                             FILE: july.cpp */
/*                                                                            */
/*  An Application For The Partial_Sum Algorithm (AAFTPSA)                    */
/*  ======================================================                    */
/*                                                                            */
/*  Compiled and tested with Visual C++ V6.0                                  */
/*                                                                            */
/*  V1.00   31-JUL-2002   P. Tellenbach   https://www.heimetli.ch/            */
/*                                                                            */
/*  Compiled and tested with g++ 11.2.0                                       */
/*                                                                            */
/*  V1.10   24-JUL-2022   P. Tellenbach   https://www.heimetli.ch/            */
/*                                                                            */
/******************************************************************************/

#include <iostream>
#include <numeric>
#include <iterator>

using namespace std ;

#define He 'H', 'e' - 'H',
#define ll 'l' - 'e', 0,
#define o  'o' - 'l', ' ' - 'o',
#define wo 'w' - ' ', 'o' - 'w',
#define rl 'r' - 'o', 'l' - 'r',
#define d  'd' - 'l', ' ' - 'd', '!' - ' ', '\n' - '!'

int values[] = { He ll o  wo rl d } ;

int main()
{
  partial_sum( values, values + 14, ostream_iterator<char>(cout) ) ;

  return 0 ;
}