这是C++书本上的例3-5
我改了一下 但不知道是那里错了 帮忙看一下啊
#include<iostream>
#include<cmath>//c++中的定义数学函数的头文件
using namespace std;
int main()
{
double k,r,s;
double tsin(double x);
cout<<"r=";
cin>>r;
cout<<"s=";
cin>>s;
if(r*r<=s*s)
k=sqrt(tsin(r)*tsin(r)+tsin(s)*tsin(s));
else
k=tsin(r*s)/2;
cout<<k<<endl;
}
double tsin(double x)
{ int a;
double g,b,sqr;
a=1;
g=0;
sqr=x*x;
whlie(fabs(e/a)>le-6) //e/a大于0.000001
{ b=e/a;
g=(e%7==1)?g+b:g-b;
e*=sqr;
a*=(a+2)*(a+1);
}
return g;
}
VC++这样显示的 Compiling...
3-5.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\3 5\3-5.cpp(17) : warning C4508: 'main' : function should return a value; 'void' return type assumed
C:\Program Files\Microsoft Visual Studio\MyProjects\3 5\3-5.cpp(24) : error C2065: 'whlie' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\3 5\3-5.cpp(24) : error C2065: 'e' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\3 5\3-5.cpp(24) : error C2065: 'le' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\3 5\3-5.cpp(25) : error C2143: syntax error : missing ';' before '{'
执行 cl.exe 时出错.
3 5.exe - 1 error(s), 0 warning(s)