#include<stdio.h>
int main()
{
double x;
while( scanf("%lf",&x)!=EOF )
{
if(x<0)
{
x=-x;
}
printf("%.2lf\n",x);
}
return 0;
}
上述代码执行结果如下:
如果编译时使用了-std=c99,则结果就不正确了:
#include<stdio.h>
int main()
{
double x;
while( scanf("%lf",&x)!=EOF )
{
if(x<0)
{
x=-x;
}
printf("%.2lf\n",x);
}
return 0;
}
上述代码执行结果如下:
如果编译时使用了-std=c99,则结果就不正确了: