写一函数求sinh(x)的值,求sinh(x)的近似值,公式为:sinh=(e^x-e^-x)/2,其中用一个函数求e^x。
#include "stdafx.h"
#include<iostream>
#include<math.h>
using namespace std;
double sinh(double a)
{
double c;
c=(a-(1/a))/2;
return c;
}
int _tmain(int argc, _TCHAR* argv[])
{
double x,y,s;
cin>>x;
y=exp(x); //y的值就是e^x次方
s=sinh(y);
cout<<s<<endl;
return 0;
}
C++中求指数e的x次幂的函数:
exp(doube x);
使用此函数之前要记得加上#include<math,h>头文件