double tan(double x);
tan() 函数的功能是求某个角的正切值。
在直角三角形 ABC 中(其中角 C 为 90°),角 A 的正切就是它的对边长度和临边长度的比值,如下图所示,tanA = a / b。
x 弧度的正切值。
求 45° 角的正切值。
由于 tan() 函数的参数是弧度,所以在给函数传递参数前,需要先将 45° 转换为弧度值。
- /* tan example */
- #include <stdio.h> /* printf */
- #include <math.h> /* tan */
- #define PI 3.14159265
- int main ()
- {
- double param, result;
- param = 45.0;
- result = tan ( param * PI / 180.0 );
- printf ("The tangent of %f degrees is %f.\n", param, result );
- return 0;
- }
运行结果: