C语言里sin函数和cos函数的调用

2025-02-18 23:43:29
推荐回答(5个)
回答1:

C语言里sin函数和cos函数是C标准数学函数库中的函数,调用需要引入math.h头文件。

一、sin() 函数描述:

C 库函数 double sin(double x) 返回弧度角 x 的正弦。sin() 函数的声明:double sin(double x)。

参数:x -- 浮点值,代表了一个以弧度表示的角度。

返回值:该函数返回 x 的正弦。

二、cos() 函数描述:

cos() 函数的功能是求某个角的余弦值。cos() 函数的声明:double cos(double x)。

参数:x -- 浮点值,代表了一个以弧度表示的角度。

返回值:该函数返回 x 的余弦。

扩展资料:

相关的三角函数:

double asin (double); 结果介于[-PI/2,PI/2]

double acos (double); 结果介于[0,PI]

double atan (double); 反正切(主值),结果介于[-PI/2,PI/2]

double atan2 (double,double); 反正切(整圆值),结果介于[-PI,PI]

参考资料来源:百度百科-math.h

回答2:

sin 函数取一角度为参数值,并返回角的对边长度除以斜边长度的比值。
结果的取值范围在 -1 到 1 之间。
为了将角度转换为弧度,请将角度乘以 π/180。
为了将弧度转换为角度,请将弧度乘以 180/π

功 能: 正弦,余弦函数
用 法: double sin(double x);
double cos(double y);

# include
# include
int main()
{
int n;
double t;
const double pi=4.0*atan(1.0);
scanf("%d",&n);
t=(n*pi)*1.0/180;
printf("%lf\n",pi);
printf("%lf\n",sin(t));
printf("%lf\n",cos(t));
return 0;
}

回答3:

是这样调用,不过 参数是 弧度,不是角度哦。
弧度=角度 *pi /180

回答4:

要预处理。全部调用与输出如下:

#include "math.h" /*数学函数头文件*/
#include "conio.h" /*getch()类函数头文件*/
#include "stdio.h"/*输入输出函数头文件*/
void main()
{
double i;
i=sin(5);
printf("%f",i);
getch();
}

回答5:

#include
貌似要加这个头文件。