课后练习4.5 写一函数求sin(x)的值,求sin(x)的近似公式为sinh(x)=(ex-e(-x))/2,其中用一个函数求e^x。
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double e(double);
double x, sinh;
cout << "enter x:";
cin >> x;
sinh = (e(x) - e(-x)) / 2;
cout << "sinh(" << x << ")=" << sinh << endl;
return 0;
}
double e(double x)
{
return exp(x);
}