📅  最后修改于: 2020-09-25 08:09:01             🧑  作者: Mango
此函数在
[Mathematics] tan x = tan(x) [In C++ Programming]
double tan(double x);
float tan(float x);
long double tan(long double x);
double tan (T x); // For integral type
tan() 函数采用一个以弧度为单位的强制性参数(可以为正,负或0)。
tan() 函数返回[-∞,∞]范围内的值。
#include
#include
using namespace std;
int main()
{
long double x = 0.99999, result;
result = tan(x);
cout << "tan(x) = " << result << endl;
double xDegrees = 60.0;
// converting degree to radians and using tan() fucntion
result = tan(xDegrees*3.14159/180);
cout << "tan(x) = " << result << endl;
return 0;
}
运行该程序时,输出为:
tan(x) = 1.55737
tan(x) = 1.73205
#include
#include
using namespace std;
int main()
{
long int x = 6;
double result;
result = tan(x);
cout << "tan(x) = " << result;
return 0;
}
运行该程序时,输出为:
tan(x) = -0.291006