用C语言求sinx的值,望高人指点
编程如下:#include<stdio.h>#include<math.h>doublefactorial(intn){inti=0;intfactory=1;if(n=...
编程如下: #include<stdio.h> #include<math.h> double factorial(int n) { int i=0; int factory=1; if(n==0) return 1; for (i=1;i<=n;i++) factorial=factorial*i; } double mysin (double x) { int i=1; double result=x,part=1; while(i<20) {part=pow(x,4*i-1)/factorial(4*i-1); part=part, result=result+part, part=pow(x,4*i+1)/factorial(4*i+1); result=result+part, part=1; i++; } return result; } void main() { double sinx=0,x=0; int m=0; printf("请输入x"); scanf("%\f",&x); sinx=mysin(x); printf("sinx=%f\n",sinx); } 但运行时出错,显示: C:\Documents and Settings\localuser\桌面\12.c(10) : error C2296: '*' : illegal, left operand has type 'double (__cdecl *)(int )' Error executing cl.exe.
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询