Home > Back-end >  For bosses to solve! Why is it that no matter what Numbers can enter into the if statements
For bosses to solve! Why is it that no matter what Numbers can enter into the if statements

Time:12-02

# include
# include
Int main ()
{
Float a, b, c, p, s;
Printf (" please enter the three Numbers: ");
The scanf (" % f, % f, % f ", & amp; A, & amp; B, & amp; C);
If ((a + b) & gt; C & amp; & (a + c) & gt; B & amp; & (b + c) & gt; A)
{
P=(float) (a + b + c)/2;
S=SQRT (s * (s - a) * (s - b) * (s - c));
Printf (" the three number can constitute a triangle, the area of % f, \ n ", s);
}
The else
{
Printf (" the three number cannot constitute a triangle \ n ");
}
fflush(stdin);
getchar();
}

CodePudding user response:

How did you enter?
Three, four, five try you input

CodePudding user response:

Three, four, five tried not

CodePudding user response:

Say your code first, s assignment should be changed to
 s=SQRT (p * (p - a) * (p - b) * (p - c));//SQRT () function in the s to p 

In your input, because the input code
 the scanf (" % f, % f, % f ", & amp; A, & amp; B, & amp; C); 

Contains a comma, so your input must also have a comma

If you don't want to add a comma when input, you can change the code to the
Code=c] the scanf (" % f % f % f ", & amp; A, & amp; B, & amp; C); [/code]

CodePudding user response:

Good idiot! I don't know why I didn't see... Thank you very much!
I input is also used in Chinese comma

CodePudding user response:

Have a look at their input format, especially the comma ~ in both Chinese and English

CodePudding user response:

Behind the scanf add print, can be found that the problem immediately
  • Related