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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
#include <iostream>
using namespace std;
void setFirst(int& first);
void setSecond(int& second);
void setThird(int& third);
int getFirst(int& first);
int getSecond(int& second);
int getThird(int& third);
int getHighest(int first, int second, int third);
int getLowest(int first, int second, int third);
int getMiddle(int first, int second, int third);
void showResults(int first, int second, int third);
int main(){
int first;
int second = 2;
int third = 3;
setFirst(first);
showResults(first, second, third);
cin >> first;
return 0;
setSecond(second);
showResults(first, second, third);
cin >> second;
return 0;
setThird(third);
showResults(first, second, third);
cin >> third;
return 0;
int getHighest(int first, int second, int third);
int getLowest(int first, int second, int third);
int getMiddle(int first, int second, int third);
void showResults(int first, int second, int third);
}
void setFirst(int& first)
{
cout << "please enter the first number: ";
cin >> first;
}
void setSecond(int& second)
{
cout << "please enter the second number: ";
cin >> second;
}
void setThird(int& third)
{
cout << "please enter the third number: ";
cin >> third;
}
int getFirst(int& first)
{
return first;
}
int getSecond(int& second)
{
return second;
}
int getThird(int& third)
{
return third;
}
int getHighest(int first, int second, int third)
{
int highest;
highest = getHighest(first, second, third);
if(getSecond(second)>highest)
highest = second;
if(getThird(third)>highest)
highest = third;
return highest;
}
int getLowest(int first, int second, int third)
{
int lowest;
lowest = getLowest(first, second, third);
if(getSecond(second)<lowest)
lowest = second;
if(getThird(third)<lowest)
lowest = third;
return lowest;
}
int getMiddle(int first, int second, int third)
{
int middle;
middle = getMiddle(first, second, third);
if(getSecond(second)>middle)
middle = second;
if(getThird(third)>middle)
middle = third;
return middle;
}
void showResults(int first, int second, int third){
cout << "the highest value was: "
<< getHighest(first,second,third) << endl;
cout << "the middle value was: "
<< getMiddle(first,second,third) << endl;
cout << "the lowest value was: "
<< getLowest(first,second,third) << endl;
}
|