1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
# include <iostream>
using namespace std;
int get_max(int a,int b,int c)
{
int tmpVar = (b>c)?b:c;
return (a>tmpVar)?a:tmpVar;
}
int get_min(int a,int b,int c)
{
int tmpVar = (b<c)?b:c;
return (a<tmpVar)?a:tmpVar;
}
int get_mid(int a,int b,int c)
{
if(a==b&&a==c)
return a;
if(a==b||a==c||b==c)
{
if(a==b)
return a;
if(a==c)
return a;
if(b==c)
return b;
}
if((a>b&&a<c)||(a<b&&a>c))
return a;
else if((b>a&&b<c)||(b<a&&b>c))
return b;
else return c;
}
int main()
{
int num1,num2,num3;
int Max,Min,Mid;
cout << "Please,Enter three numbers" << endl;
cin >> num1 >> num2 >> num3;
Max = get_max(num1,num2,num3);
Min = get_min(num1,num2,num3);
cout << "The max : " << Max << endl;
cout << "The min : " << Min << endl;
// For me with num1,num2,num3 ,middle function could be compilcated because we
// could have two numbers or three equal
Mid = get_mid(num1,num2,num3);
cout << "The mid : " << Mid << endl;
return 0;
}
|