Southeast University C++复试:2011_01

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double calculateE( int );

int main()
{
	int expOfE;
	cout << " Enter the exception of e:";
	cin >> expOfE;
	cout << fixed << setprecision( 10 );
	cout << calculateE( expOfE ) << endl;
}

double calculateE( int exp ) 
{
	double result = 1;
	int x = exp;
	int i = 1;
	double poly = 1;
	while( exp > 10e-10)
	{
		poly *= (x * poly / i); 
		result += poly ;
		exp--;
	}
	return result;
}
发布了11 篇原创文章 · 获赞 7 · 访问量 5254

猜你喜欢

转载自blog.csdn.net/qq_35591140/article/details/105503347