《c语言sin函数.docx》由会员分享,可在线阅读,更多相关《c语言sin函数.docx(5页珍藏版)》请在三一办公上搜索。
1、c语言sin函数#include stdio.h#include math.h#define pai 3.14159265358979#define pai 3.14159265358979double jiecheng(double a)double ai;if(a=1)return 1;ai=a*jiecheng(a-1);return(ai);double sin0pai2(double a)double ai=0.0;int i,e=1;for(i=1;i+)ai+=(e/(jiecheng(2*i-1)*(pow(a,2*i-1);e=e*(-1);if(pow(a,2*i+1)/(
2、jiecheng(2*i+1)<0.00000000001)break;return(ai);double sind02(double a)double ai;if(2*pai<=a)while(a>=2*pai)a=a-2*pai;if(a=0)return 0;if(a=(pai/2)return 1;if(a=pai)return 0; if(a=pai/2*3)return -1; if(0<a<(pai/2) ai=sin0pai2(a);return(ai);if(pai/2)<a<pai)a=pai-a;ai=sin0pai2(a);return(ai
3、);if(pai<a<pai/2*3)a=a-pai;ai=sin0pai2(a);return(-ai); if(pai/2*3<a<2*pai)a=2*pai-a;ai=sin0pai2(a);return(-ai); double sin2(double a)double ai;if(a>=0)ai=sind02(a);return(ai);if(a<0)a=-a;ai=sind02(a);return(-ai);maindouble a,b,c;printf(inputh the datan);scanf(%lf,&a);c=a/180*pai;b=sin2(c);printf(sin%lf=%lf,a,b);