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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include <iostream>
using namespace std;
int main()
{
int a, b, c, d;
cout << "Choose 4 numbers and I will tell you which ones is the highest." << endl
<< "Type in 4 numbers with space between: ";
cin >> a;
cin >> b;
cin >> c;
cin >> d;
// Checks if all the numbers match.
if (a==b && b==c && c==d )
cout << "All the numbers match, all being " << d;
// Checks if A is the highest.
else if (a>b && a>c && a>d)
cout << "The first number is the highest, being " << a;
// Checks if b is the highest.
else if (b>a && b>c && b>d)
cout << "The second number is the highest, being " << b;
// Checks if c is the highest.
else if (c>a && c>b && c>d)
cout << "The third number is the highest, being " << c;
// Checks if c is the highest.
else if (d>a && d>b && d>c)
cout << "The last number is the highest, being " << d;
// Checks if two of the numbers matches and being the highest
else if (a>c && a>d && a==b) // a b * *
cout << "The first and the second number are the highest, being " << a;
else if (a>b && a>d && a==c) // a * c *
cout << "The first and the third number are the highest, being " << a;
else if (a>b && a>c && a==d) // a * * d
cout << "The first and the last number are the highest, being " << a;
else if (b>a && b>d && b==c) // * b c *
cout << "The second and third number are the highest, being " << b;
else if (b>a && b>c && b==d) // * b * d
cout << "The second and the last number are the highest, being " << b;
else if (c>a && c>b && c==d) // * * c d
cout << "The third and the last number are the highest, being " << c;
// Checks if 3 numbers match each other
else if (a>d && a==b && a==c) // a b c *
cout << "The first three numbers are the highest, being " << a;
else if (a>b && a==c && a==d) // a * c d
cout << "The first and the two last numbers are the highest, being " << a;
else if (a>c && a==b && a==d) // a b * d
cout << "The first and the two last numbers are the highest, being " << a;
else
cout << "The three last numbers are the highest, being " << c;
cout << ".";
return 0;
}
|