Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102854327
main.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 24, 21:29
Size
721 B
Mime Type
text/x-c
Expires
Wed, Feb 26, 21:29 (2 d)
Engine
blob
Format
Raw Data
Handle
24432332
Attached To
R7571 SP4E-TB-TL-FR
main.cc
View Options
/* -------------------------------------------------------------------------- */
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
/* -------------------------------------------------------------------------- */
int main(int argc, char ** argv){
unsigned long maxiter = atof(argv[1]);
float pi = 0.;
float pi2 = 0.;
for (unsigned long k = 1 ; k < maxiter ; ++k){
pi += 1./(1.*k*k);
unsigned long k2 = maxiter-k;
pi2 += 1./(1.*k2*k2);
}
pi *= 6.;
pi2 *= 6.;
std::cout << std::scientific << std::setprecision(15)
<< pi << " " << pi2 << " " << M_PI*M_PI
<< " " << pi - M_PI*M_PI << " " << pi2 - M_PI*M_PI << std::endl;
return EXIT_SUCCESS;
}
Event Timeline
Log In to Comment