C语言中的三角函数计算需要将角度转弧度,,比如以下代码是计算sin()的值:
#include"stdio.h"
#include"math.h"
main()
{
int i;
float t;
printf("请输入要计算的角度:");
scanf("%d",i);
printf("sin(%d)=%f",i,t);
}
sum = fun(x,y,z); //这里,应当接收函数的返回值
printf("f(x,y,z)=%f\n",sum);
调用math.h中的三角函数,需要将角度值变换为弧度值,代码如下:
#includestdio.h
#includemath.h
int main()
float st,a;
scanf("%f",st);
printf("sin(st)=%f\n", sin(a));
printf("cos(st)=%f\n", cos(a));
return 0;
包含头文件math.h后,所有三角函数的库函数就都可以直接引用了.比如求x的正弦就用sin(x),它返回一个double值.注意x以弧度计......
以上就是土嘎嘎小编为大家整理的c语言中三角函数相加相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!