double sinx(double x)
{
double result=x,temp=x;
double den=x,fac=1;
int n=1,sign=1;
while((temp>1e-5)||(temp<-1e-5))
{
n++,fac*=n,den*=x;
n++,fac*=n,den*=x;
temp=den/fac;sign=-sign;
result=sign>0?result+temp:result-temp;
}
return result;
}
double cosx(double x)
{
x=1.57079-x;
return sinx(x);
}
main()
{
double a,b,c;
scanf("%lf",&a);
b=sinx(a);
c=cosx(a);
printf("sin(%lf)=%lf,cos(%lf)=%lf",a,b,a,c);
}
温馨提示:答案为网友推荐,仅供参考