题目:
代码:
#include<stdio.h>
#include<math.h>
int main(){int sign=1,n=1;double x=3,term,a,sinx=0;//scanf("%lf",&x);term=x;while(fabs(term)>=0.00001){sinx+=sign*term;n=n+2;a=pow(x,n);double b=1;for(int i=1;i<=n;i++){b*=i;}term=a/b;sign=-sign; }printf("累加项为%d",(n+1)/2);printf("sinx为%f__sin(x)为%f",sinx,sin(x));
}
结果