求实数绝对值

求实数绝对值



#include <stdio.h>
#include <math.h>
double zxd (double x);
int main()
{
    double x;
    while (scanf("%lf", &x)!=EOF)
    {
        double y = zxd(x);
        printf("%.2lf\n",y);
    }
    return 0;
}
double zxd (double x)
{
    double z;
    if(x>=0)
    {
        z=x;
    }
    else
    {
        z = -x;
    }
    return z;
}