Home > Back-end > The maximum value of the three Numbers with function, the minimum value, median, and sorted
The maximum value of the three Numbers with function, the minimum value, median, and sorted
Time:09-15
Why run results is not the correct number and two random Numbers, and bosses guidance solutions
CodePudding user response:
Or you just paste the code! Why we write the code again
CodePudding user response:
I wrote a program, the code is as follows:
#include using namespace std;
Int main () { Int a, b, c; Int qmax (int a, b int, int) c; Int qmin (int a, b int, int) c; The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C); Int Max=qmax (a, b, c); Int min=qmin (a, b, c); Int mid=a + b + c - (Max + min); Printf (" maximum value for: % d, median: % d, minimum value is: % d \ n ", Max, mid, min); Printf (" sorted: \ n "); Printf (" % d % d % d \ n ", Max, mid, min); return 0; } Int qmax (int a, b int, int) c { Int Max; Max=(a> B)? (a> C? A: c) : (b> C? B, c); The return of Max; } Int qmin (int d, int e, int f) { Int min; Min=(dReturn min; }
The result of the running as shown in figure:
You are so there is no problem
CodePudding user response:
This is the only the tip of direct sort:
#include
Void the sort (int & amp; A, int & amp; B, int & amp; C) { If (b & gt; C) c +=b=c, b=c - b; If (a & gt; B) b +=a=b, a=b - a; If (b & gt; C) c +=b=c, b=c - b; }
Int main () { Int a, b, c;
Puts (" enter 3 Numbers: "); The scanf (" % d % d % d ", & amp; A, & amp; B, & amp; C); Sort (a, b, c); Printf (" Max=% d, min=% d, median=% d \ n ", c, a, b);