Re: [Haskell-cafe] A tale of Project Euler

Michaeljohn Clement wrote:
Andrew Coppin wrote:
First, somebody else wrote this in C:
int n = 2 , m , primesFound = 0;
for( n=0;n < MAX_NUMBERS;n++ ) if( prime[n] ) { primesFound++;
if( primesFound == 10001 ) cout << n << " is the 10001st prime." << endl;
Um, I can't *believe* nobody else pointed this out, but that isn't C, it's C++.
Really? How can you tell? Well anyway, the guy who wrote it said it's C. I suppose it was a simple oversight...

On Nov 28, 2007 9:28 PM, Andrew Coppin
Michaeljohn Clement wrote:
Andrew Coppin wrote:
First, somebody else wrote this in C:
int n = 2 , m , primesFound = 0;
for( n=0;n < MAX_NUMBERS;n++ ) if( prime[n] ) { primesFound++;
if( primesFound == 10001 ) cout << n << " is the 10001st prime." << endl;
Um, I can't *believe* nobody else pointed this out, but that isn't C, it's C++.
Really? How can you tell?
cout, endl etc. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862

On Nov 28, 2007, at 16:28 , Andrew Coppin wrote:
Michaeljohn Clement wrote:
Andrew Coppin wrote:
First, somebody else wrote this in C:
int n = 2 , m , primesFound = 0;
for( n=0;n < MAX_NUMBERS;n++ ) if( prime[n] ) { primesFound++;
if( primesFound == 10001 ) cout << n << " is the 10001st prime." << endl;
Um, I can't *believe* nobody else pointed this out, but that isn't C, it's C++.
Really? How can you tell?
Strictly speaking, the I/O is done with C++ operators and variables. But the actual algorithm is C, if you replace the cout << ... with printf() then the whole thing will be C. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (3)
-
Andrew Coppin
-
Brandon S. Allbery KF8NH
-
Sebastian Sylvan