一道c++編程題 好久都沒有找出來哪裡出錯 麻煩各位高手幫忙看看
程序代码:
#include"iostream.h" #include"math.h" int jiecheng(int x) { int j,k; for(j=1,k=1;j<=x;j++) k=k*j; return k; } double fun(double x,double eps=1e-6) { double s; int i; for(i=1,s=x;pow(x,2*i+1)/jiecheng(2*i+1)>eps;i++) { s=s+pow(-1,i)*pow(x,2*i+1)/jiecheng(2*i+1); } s=s+pow(-1,i)*pow(x,2*i+1)/jiecheng(2*i+1); return s; } void main() { double x; cout<<"Input x please x="; cin>>x; cout<<'\n'<<fun(x)<<'\n'; }