做算y=sinx的程序,不能用库函数
											如题刚学c语言,不熟悉运用操作和算法,望大家帮忙
[此贴子已经被作者于2006-3-1 23:28:15编辑过]
compiled to void, faint 'n pfft.
#include <stdio.h>
main()
{double sinx();
long int prod();
long int cf();
float x;
scanf("%f",&x);
printf("sin(%f)=%f",x,sinx(x));
}
/*阶乘函数*/
long int prod(int c)
{ long int b;
  if (c<=1) return (1);
  { b=(c+1)*prod(c--);
    return b;
  }
}
/*指数函数*/
long int cf(int a, int b)
{ int i;
  long int c=a;
  for (i=0;i<b;i++)
  c=c*a;
  return c;
}
/*sin()函数*/
double sinx(float y)
{
int n=0,m=0;
double d=6,z=0,x=0;
for (n=0; d>0.001; n++)
{m=2*n+1;
  d=1/prod(m);
  x=cf(y,m);
  z=z+(cf(-1,n)/d)*x;
}
  return z;
}
[此贴子已经被作者于2006-3-2 11:18:58编辑过]

 老大,谁让你算圆周率的值了
 老大,谁让你算圆周率的值了

