atan()函数计算参数的反正切值。
double atan(double x);
函数atan()将单个double x作为参数,并返回以弧度表示的值。
atan()返回的值类型是double。
为了更好地了解atan():
[Mathematics] tan-1x = atan(x) [In C programming]
它在<math.h>头文件中定义。
库函数atan()取从负到正的任何值。
#include <stdio.h>
#include <math.h>
#define PI 3.141592654
int main()
{
double num = 1.0;
double result;
result = atan(num);
printf("tan(%.2f) 的反正切是 = %.2f 弧度", num, result);
//将弧度转换成角度
result = (result * 180) / PI;
printf("\ntan(%.2f) 的反正切是 = %.2f 度", num, result);
return 0;
}输出结果
cos(1.00) 的反正切是 = 0.79 弧度 cos(1.00) 的反正切是 = 45 度