Created
February 25, 2011 13:10
-
-
Save JaDogg/843763 to your computer and use it in GitHub Desktop.
paper1b_1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include <cmath> | |
using namespace std; | |
int main() | |
{ | |
int m_upper; | |
double x,B = 0.0,den; | |
cout << "input m's upper limit :"; cin >> m_upper; | |
if (m_upper < 0) | |
{ | |
cout << "m's upper limit cannot be smaller than 0" << endl; | |
return -1; | |
} | |
cout << "input x :"; cin >> x ; | |
for(int m = 0;m<= m_upper;m++) | |
{ | |
den = 1.0; | |
for(int a = 1;a <= 2*m;a++) | |
{ | |
den *= double(a); | |
} | |
B += pow(x,double(2*m)) / den; | |
} | |
cout << "B = "; | |
cout << setiosflags(ios::fixed) << setprecision(3); | |
cout << B; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment