C语言sin()用来计算参数x
的正玄值,然后将结果返回.返回-1
之间的计算结果.
例子:
#include
math.h
main(){
double
answer
=
%f\n",
answer);
}
执行
C语言sin():
sin()原型:double
sin(double
x)
sin()角度与弧度:
扩展资料:
与sin相似的acos函数
函数名:
acos
功
能:计算并返回arccos(x)值、要求-1=X=1
函数与形参类型:
acos(x)
x;
程序例:
stdio.h
int
main(void)
{
result;
x
result
acos(x);
printf("The
arc
cosine
of
%lf
is
%lf\n",
x,
result);
return
0;
参考资料:CSDN博客频道-C语言中sin和cos的用法
#include?math.h
#include?stdio.h
#define?FRE?1
void?main()
int?f=FRE;
int?i;
double?y,t;
y?=?0;
i?=?1;
while(i?=?MAX_NUM)
printf("[%f]\n",y);
C语言中要编写sin函数,实质上要利用sin的泰勒公式,然后根据泰勒公式,将其中的每一项进行分解,最后用循环,累加计算出最终结果
下面用for循环实现sin的算法,程序代码如下:
#includestdio.h
#includemath.h
void main()
int ?i;
float ?x,sum,a,b; ?//sum代表和,a为分子,b为分母
char s;
printf("please input x");
scanf("%f",x);
s=1;
sum=0;
a=x; ? ? //分母赋初值
b=1; ? ? //分子赋初值
sum=sum+s*a/b; ? ?//累加一项
a=a*x*x; ? ? //求下一项分子
s*=-1;
printf("sum=%f\n",sum);
以上就是土嘎嘎小编为大家整理的c语言sin函数求和相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!