高手进来帮忙看看这段代码
有高手再不?帮我看看,我这个程序有什么地方错了,调试的时候没有抱错,但就是还没运行完就停了
int main()
{
int cumu(int k);
double power(double x,int k);
double x;
cout<<"input x"<<endl;
cin>>x;
double g=0.0,t=x,p=0.000001;
int n=1;
do
{
g=g+t;
n++;
t=power(-1,n-1)*power(x,2*n-1)/cumu(2*n-1);
}while(fabs(t)>=p);
cout<<g<<endl;
}
//------------------------------------------------------------------------------------------------------------------
int cumu(int k)
{
int g=1,i=1;
while(i<=k)
{
g=g*i;
i++;
}
return g;
}
//------------------------------------------------------------------------------------------------------------------
double power(double x,int k)
{
double h=1.0;
int i=1;
while(i<=k)
{
h=h*x;
i++;
}
return h;
}