CISP-PTE-编程题
2014
#include <iostream>
using namespace std;
double H(int n,double x)
{
if (n > 1)
return 2 * x*H(n - 1, x) - 2 * (n - 1)*H(n - 2, x);
if (n == 0)
return 1;
if (n == 1)
return 2 * x;
}
int main()
{
int n;
double x,result;
cin >> n;
cin >> x;
result = H(n,x);
cout << result;
return 0;
}
#include<iostream>
#include<cmath>
using namespace std;
long double fun(long double n)
{
return pow((1 + 1 / n), n);
}
int main()
{
long double n = 1;
long double oldResult = 3;
long double newResult=2;
while (fabs(newResult - oldResult) >= 0.000001)
{
n++;
oldResult = newResult;
newResult=fun(n);
}
cout <<newResult<<" "<< n<<endl;
return 0;
}