该函数查找以弧度指定的角度的切线。
float tan(float x); double tan(double x); long double tan(long double x); double tan(integral x);
x :以弧度表示的值。
它返回以弧度表示的角度的切线。
让我们看一个简单的例子,当x的值为正时。
链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-tan-function.html
来源:LearnFk无涯教程网
#include <iostream> #include<math.h> using namespace std; int main() { float degree=10; float radian=degree*3.14/180; cout<<"Tangent of an angle is : "<<tan(radian); return 0; }
输出:
Tangent of an angle is : 0.176236
在此示例中,当度数的值等于10时,tan()函数计算角度的切线。
让我们看一个简单的例子,当度的值为负时。
#include <iostream> #include<math.h> using namespace std; int main() { float degree= -60; float radian=degree*3.14/180; cout<<"Tangent of an angle is :"<<tan(radian); return 0; }
输出:
Tangent of an angle is :-1.72993
在此示例中,tan()函数在度的值为负(即-60)时计算角度的切线。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
HarmonyOS快速入门与实战 -〔QCon+案例研习社〕