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
|
#include <iostream>
using namespace std;
bool isDifferent(int x, int y, int z)
{
if (!(x == y == z))
return true;
return false;
}
int max_of_three(int x, int y, int z)
{
int greater_of_two(int, int);
int first_comparison = greater_of_two(x, y);
int second_comparison = greater_of_two(first_comparison, z);
return second_comparison;
}
int greater_of_two(int first_number, int second_number)
{
if (first_number > second_number)
return first_number;
return second_number;
}
int min_of_three(int x, int y, int z)
{
int smaller_of_two(int x, int y);
int first_comparison = smaller_of_two(x, y);
int second_comparison = smaller_of_two(first_comparison, z);
return second_comparison;
}
int smaller_of_two(int first_number, int second_number)
{
if (first_number < second_number)
return first_number;
return second_number;
}
void print_result(int max, int min)
{
cout << "The maximum of the three numbers is " << max << ", and the minimum of the three numbers is " << min_of_three << endl;
}
int main()
{
bool isDifferent(int, int, int);
int max_of_three(int, int, int);
int min_of_three(int, int, int);
void print_result(int, int);
int a, b, c;
while (isDifferent == false)
{
cout << "Please enter an integer" << endl;
cin >> a;
cout << "Please enter an integer" << endl;
cin >> b;
cout << "Please enter an integer" << endl;
cin >> c;
}
int max = max_of_three(a, b, c);
int min = min_of_three(a, b, c);
print_result(max, min);
system("pause");
return 0;
}
|