c++调试除了很多错,不知道怎么解决
代码:#include "math.h"
#include "stdio.h"
#define f(x)=x*x+2*x
double hj(double *a,double *b,double e,int *n)
{
double x1,x2,s;
if (fabs(*b-*a)<=e)
s = f((*b+*a)/2);
else { x1=*b-0.618*(*b-*a); x2=*a+0.618*(*b-*a);
if (f(x1) >f(x2))
else *b=x2;
*n=*n+1;
s=hj(a,b,e,n);
}
return s;
}
main()
{
double s,a,b,e;
int n=0;
scanf("%lf %lf %lf",&a,&b,&e);
s=hj(&a,&b,e,&n);
print f("a=chatlf,b=charlf,s=charlf,n=charlf,n=%d\n",a,b,s,n);
}
错误:-Configuration: zuoye1 - Win32 Debug--------------------
Compiling...
zuoye1.cpp
E:\homework\zuoye1\zuoye1.cpp(8) : error C2059: syntax error : '='
E:\homework\zuoye1\zuoye1.cpp(10) : error C2059: syntax error : '='
E:\homework\zuoye1\zuoye1.cpp(23) : warning C4002: too many actual parameters for macro 'f'
E:\homework\zuoye1\zuoye1.cpp(23) : error C2065: 'print' : undeclared identifier
E:\homework\zuoye1\zuoye1.cpp(23) : error C2296: '*' : illegal, left operand has type 'char [42]'
E:\homework\zuoye1\zuoye1.cpp(23) : error C2297: '*' : illegal, right operand has type 'char [42]'
E:\homework\zuoye1\zuoye1.cpp(23) : error C2297: '*' : illegal, right operand has type 'char [42]'
E:\homework\zuoye1\zuoye1.cpp(24) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.
zuoye1.obj - 1 error(s), 0 warning(s)
因为要写论文,当初学的是VB,没学过C语言,所以不会弄这个,纯属边学边写的。
不知道怎么解决上述错误,希望有人能帮帮我,谢谢!!!