Home > Back-end >  Input integers a, b, c, a maximum output, why do I always wrong in this
Input integers a, b, c, a maximum output, why do I always wrong in this

Time:10-15

#include
Int main ()
{
Int a, b, c, Max;
The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C);
If (a & gt; C)
Max=a;
The else
Max=c;
If (Max & gt; B)
Max=Max;
The else
Max=b;
Printf (" % d \ n ", Max).
return 0;
}

CodePudding user response:

The test will be a problem;

Code is redundant, change;

 # include 

Int main ()
{
Int a, b, c, Max;

The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C);
If (a & gt; C)
Max=a;
The else
Max=c;

If (Max & lt; B)
Max=b;
//Max=Max;
//else
//Max=b;
Printf (" % d \ n ", Max).
return 0;
}

The original poster is how the test?

 Max=a & gt; c ? ((a & gt; B)? A: b) : ((b & gt; C)? B, c); 

A statement, but a little complicated, according to own understanding to choose that way

CodePudding user response:

Where is wrong??????

CodePudding user response:

The
refer to the original poster ly93969 response:
# include
Int main ()
{
Int a, b, c, Max;
The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C);
If (a & gt; C)
Max=a;
The else
Max=c;
If (Max & gt; B)
Max=Max;
The else
Max=b;
Printf (" % d \ n ", Max).
return 0;
}

#include
Int main ()
{
Int a, b, c, Max;
The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C);
max=a;
If (a & lt; B)
{
If (b & lt; C)
Max=c;
The else
max=b;
}
Printf (" % d \ n ", Max).
return 0;
}

CodePudding user response:

The
reference 3 floor qq_51590857 response:
Quote: refer to the original poster ly93969 response:
# include
Int main ()
{
Int a, b, c, Max;
The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C);
If (a & gt; C)
Max=a;
The else
Max=c;
If (Max & gt; B)
Max=Max;
The else
Max=b;
Printf (" % d \ n ", Max).
return 0;
}

#include
Int main ()
{
Int a, b, c, Max;
The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C);
max=a;
If (a & lt; B)
{
If (b & lt; C)
Max=c;
The else
max=b;
}
Printf (" % d \ n ", Max).
return 0;
}

Your code has a problem, if a & gt; B and a & lt; The situation does not consider ~ c