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