请大家看下问题在那里?
请大家看下错在那里求x的反正切值
#define pi3.1415926
#include <math.h>
doublex;
D_L=atan(x)*double(180)/pi;
运行后提示错误如下:
chong.c - 3 errors
1130, 22 Illegal expression.
1130, 28 Found 'int' expected a function.
1130, 33 Operands of * have illegal types 'double' and 'void' 记得这是要加分号在后面吧兄弟?
#define pi3.1415926; D_L=atan(x)*double(180)/pi;
改成这样试试
D_L=atan(x)*((double)(180/pi)); 或者压缩上来,大家一起查查! 设X=1,
运行
D_L=atan(x)*((double)(180/pi));后
D_L=31.82
按理应D_L=45吧 设X=1,
运行
D_L=atan(x)*((double)(180/pi));后
D_L=31.82
按理应D_L=45度 吧 本帖最后由 netcreature 于 2008-12-24 14:29 编辑
#define pi 3.1415926
double x;
double D_L;
x=1.0;
D_L=atan(x)*180/pi;
测试返回值为:45.00
不知道你为什么会出现这种情况?
页:
[1]