using System; public class BinTree { public BinTree left; public BinTree right; public int value; public BinTree( int depth ) { value = 1; if ( depth <= 1 ) { left = null; right = null; } else { left = new BinTree( depth - 1 ); right = new BinTree( depth - 1 ); } } } class SumBinTree { public static void Main( String[] args ) { int depth = System.Convert.ToInt32( args [ 0 ] ); SumBinTree sbt = new SumBinTree(); BinTree btree = new BinTree( depth ); sbt.Sum( btree, sbt.c ); Console.WriteLine( "Sum = " + sbt.Get() ); } int Get() & Channel c( int x ) { return ( x ); } movable Sum( BinTree btree, Channel( int ) c ) { if ( btree.left == null ) c.Send( btree.value ); else { SumBinTree sbt = new SumBinTree(); Sum( btree.left, sbt.c1 ); Sum( btree.right, sbt.c2 ); c.Send( sbt.Get2() ); } } int Get2() & Channel c1( int x ) & Channel c2( int y ) { return x + y; } }