第1个回答 2009-03-18
你用的是什麼编译器阿?
错误信息是什麼
你这个代码里面还有个问题
if(x>=0) //浮点数是不能这样与0必较的
如果判"x == 0.0"
x> -极大值 && x< +极小值
fabs(x) < 极小值(趋近於0)
第2个回答 2009-03-18
这个程序完全正确,在DEV C++下编译通过,而且DEV C++是很标准的,我帮你简化下程序
#include<stdio.h>
main()
{
float x;
scanf("%f",&x);
printf("%f",x>=0?x:-x);
}
第3个回答 2009-03-18
#include<stdio.h>
main()
{
float x;
scanf("%f",&x);
if(x>=0)
printf("%f",x);
else {
x=-x;
printf("%f",x);
}
}