这个小程序中有什么问题
//本小程序运行时感觉不对,但又不知问题出在哪。
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double f,x,a;
f=1;
int k=2;
cin> > x;
a=-x*x/2;
while(fabs(f)> 0.0001)
{
f=a+f;
k=k+2;
a=-a*x*x/k/(k-1);
}
cout < <f < <endl;
return 0;
}
[解决办法]
while里出不来..