#include <iostream>
#define PI 3.1415926
double sin(double x)
{
double s;
if(x>2*PI)
x-=2*PI*(int)(x/PI/2);
if(x*2>PI)
if(x<PI)
s=sin(PI-x);
else if(x*2<PI*3)
s=-sin(PI-x);
else
s=-sin(x);
else
{
double a=x,b=1,t,r=0,xx=x*x,s=1,i=3;
do
{
t=a/b;
r+=t*s;
a=a*xx;
b=b*i;
i+=2;
s=s==1?-1:1;
}while(t>1e-5);
return r;
}
return s;
}
int main()
{
using namespace std;
double x;
cout<<"请输入x值:";cin>>x;
cout<<"sin(x)="<<sin(x);
return 0;
}