#include<stdio.h>
#include<math.h>
double sin(double);
double nResult(double,double);
int main()
{
double x=0;
scanf("%lf",&x);
printf("sin(%lf)=%lf\n",x,sin(x));
return 0;
}
double sin(double x)
{
//sin(x)=x-x^3/3!+x^5/5!-x^7/7!+……+(-1)(n^2n+1)/(2n+1)!+……
int i=0;
double result=0,n=0;
while( fabs( n=nResult(x,2*++i-1) ) > 0e-7 )//绝对值大于10^-7次方就循环
result+=(i%2==1)?n:-n;
return result;
}
double nResult(double x,double n)
{
//(n^2n+1)/(2n+1)!也就是n/1*n/2*n/3*n/4*.....n/(2n+1)
return n==1?x:nResult(x,n-1)*x/n;
}