Initial commit

This commit is contained in:
Michael Reber
2019-11-15 12:59:38 +01:00
parent 40a414d210
commit b880c3ccde
6814 changed files with 379441 additions and 0 deletions
@@ -0,0 +1,28 @@
Fig10_45.cpp - Better algorithm to replace fig10_43.c (see text)
#include <iostream.h>
#include "vector.h"
/* START: Fig10_45.txt */
double eval( int n )
{
vector<double> c( n + 1 );
c[ 0 ] = 1.0;
for( int i = 1; i <= n; i++ )
{
double sum = 0.0;
for( int j = 0; j < i; j++ )
sum += c[ j ];
c[ i ] = 2.0 * sum / i + i;
}
return c[ n ];
}
/* END */
int main( )
{
cout << "eval( 10 ) = " << eval( 10 ) << endl;
return 0;
}