我在看钱能的C++书,在第四章求PI过程中遇到了麻烦,下面是我的程序,麻烦请看一下编译时:missing function header (old-style formal list?)Error executing cl.exe.可是少哪个头文件呢?问题可能比较简单,请不要见笑。谢谢。
#include<stdio.h>#include <iostream.h>#include <iomanip.h>#include <math.h>
///求pi,用公式pi/4=1-1/3+1/5+1/7.....直到最后一个的绝对值不大于1e-8
{ double sum=0,Lterm=1;int m=-1;
for(int n=1;fabs(Lterm)>1e-8;n+=2)
{temp1=(-1)*m;Lterm=1/double(n); sum+=temp1*Lterm;
}sum=4*sum;
cout<<"the pi is "<<sum<<endl;
}
评论