#include<stdio.h>
#include<math.h>
main()
{
double x,eps,s,y=0,y0,t;
int n,j;
printf("Enter x & eps:");
scanf("%lf%lf",&x,&eps);
n=t=j=1;
s=x;
do
{
y0=y;
if(n%2==0)
y=y-s/t;
else
y=y+s/t;
s*=x*x;
t=t*(j+1)*(j+2);
n++;
j+=2;
}while(fabs(y0-y)>eps);
printf("%f %lf\n",sin(x),y);
}
近似计算sin(x)
最新推荐文章于 2022-12-17 01:29:57 发布