[Shootout-list] GCC C++ Harmonic
Daniel Skiles
Daniel Skiles <dskiles@gmail.com>
Sat, 19 Mar 2005 11:39:14 -0500
------=_Part_2017_24442019.1111250354407
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hey all,
Here is a version of the harmonic test for gcc C++. I made it on
Windows using Dev C++, so let me know if it contains anything that
might invalidate it.
Daniel
------=_Part_2017_24442019.1111250354407
Content-Type: text/plain; name="main.cpp"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="main.cpp"
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char *argv[])
{
double n;
double partialSum =3D 0;
n =3D (argc =3D=3D 2) ? atof(argv[1]) : 10000000;
cout << setiosflags(ios::fixed) << setprecision(9);
=20
for(double i=3D1; i<=3Dn; i++)
partialSum +=3D 1.0/i;
cout << partialSum; =20
return EXIT_SUCCESS;
}
------=_Part_2017_24442019.1111250354407--