#include <iostream>
using namespace std;
const double pi=3.1415926;
double mysin(double n)
{
double sum=0;
double i=1;
double sign=-1;
double xx=n;
double jiecheng=1;
while(xx/jiecheng>=1e-5)
{
sign=-1*sign;
sum=sum+(sign*xx)/jiecheng;
jiecheng=jiecheng*(i+1)*(i+2);
i=i+2;
xx=xx*n*n;
}
return sum;
}
int main()
{
cout <<"sin(π/2)的值为"<<mysin(pi/2)<<endl;
double a;
a=pi*56.0/180.0;
cout<<"sin(56)的值为"<<mysin(a);
return 0;
}
using namespace std;
const double pi=3.1415926;
double mysin(double n)
{
double sum=0;
double i=1;
double sign=-1;
double xx=n;
double jiecheng=1;
while(xx/jiecheng>=1e-5)
{
sign=-1*sign;
sum=sum+(sign*xx)/jiecheng;
jiecheng=jiecheng*(i+1)*(i+2);
i=i+2;
xx=xx*n*n;
}
return sum;
}
int main()
{
cout <<"sin(π/2)的值为"<<mysin(pi/2)<<endl;
double a;
a=pi*56.0/180.0;
cout<<"sin(56)的值为"<<mysin(a);
return 0;
}