Why are double right and floating point wrong?

This is a double edition.

# include & ltstdio.h & gt

# include & ltmath.h & gt

int main()

{

Double a, b, c, p, zone;

While(scanf("%lf%lf%lf ",& one, & ampb & amp;; c)! =EOF)

{

if(a+b & gt; c & amp& ampa+c & gt; b & amp& ampb+ c & gt; answer

{

p = 0.5 *(a+b+c);

area = sqrt(p *(p-a)*(p-b)*(p-c));

printf("%.3lf\n ",area);

}

other

Printf ("impossible \ n");

}

Returns 0;

}

This is a floating version,

# include & ltstdio.h & gt

# include & ltmath.h & gt

int main()

{

Floating a, b, c, p, area;

While (scanf ("%f% f", & a, & c)! =EOF)

{

if(a+b & gt; c & amp& ampa+c & gt; b & amp& ampb+ c & gt; answer

{

p = 0.5 *(a+b+c);

area =(float)sqrt(p *(p-a)*(p-b)*(p-c));

printf("%.3f\n ",area);

}

other

Printf ("impossible \ n");

}

Returns 0;

}

Both float and double are correct. As for their mistakes after your submission, I think it should be the reason for their brain damage.

People are alive, programs are written by people, and programs are alive, so there is more than one answer. This program can be calculated without sqrt function, and the calculation method of area can vary widely. In a word, you are right.

In addition, the return value of sqrt () is double. You can view the definitions in the math.h file.

As for the float precision, digits and oral double mentioned by xslu, I don't think it has anything to do with this topic. The landlord has completely met the requirements of the topic and the result is completely correct. Why is it wrong? Give me a reason? If the reason is that float is not as common as double, then I want to ask, how should float be used? My favorite is the goto statement. Assembly language without goto statement is completely unreliable. Whether it's goto or something, I think these are tools. We are still alive. As long as we live to use dead tools, we can totally do it. There are no rules or restrictions.

In addition, there is nothing wrong with this while loop, because it is not required by the title.

I'm C. I've talked too much. Anyway, the general meaning is that the landlord is right, and you can completely question the thing that judges that your program is wrong.

It should be noted that double is used in many places in the system, and the constant 0.5 is also a double type. It is recommended to use double and float, which is much more efficient than double.