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
|
#include <iostream>
void findscore(int&, int&, int&, int&, int&);
int calcscore();
int finlowest();
int findhighest();
using namespace std;
int main()
{
int s1, s2, s3, s4, s5;
findscore(s1, s2, s3, s4, s5);
cout << s1;
system("pause");
}
void findscore(int& s1, int& s2, int& s3, int& s4, int& s5)
{
cout << "Scores are between 0 and 10\nJudges, please enter your scores:\n\nFirst judge: ";
cin >> s1;
cout << "\nSecond judge: ";
cin >> s2;
cout << "\nThird judge: ";
cin >> s3;
cout << "\nFourth judge: ";
cin >> s4;
cout << "\nFifth judge: ";
cin >> s5;
}
int calcscore()
{
int s1, s2, s3, s4, s5, sum, avg, low, high;
findscore(s1, s2, s3, s4, s5);
findlowest() = low;
findhighest() = high;
sum = s1 + s2 + s3 + s4 + s5 - low - high;
avg = sum / 3;
return avg;
}
int findlowest()
{
int s1, s2, s3, s4, s5, lowscore;
findscore(s1, s2, s3, s4, s5);
lowscore = s1;
if (lowscore > s2)
lowscore = s2;
else if (lowscore > s3)
lowscore = s3;
else if (lowscore > s4)
lowscore = s4;
else if (lowscore > s5)
lowscore = s5;
return lowscore;
}
int findhighest()
{
int s1, s2, s3, s4, s5, highscore;
findscore(s1, s2, s3, s4, s5);
highscore = s1;
if (highscore > s2)
highscore = s2;
else if (highscore > s3)
highscore = s3;
else if (highscore > s4)
highscore = s4;
else if (highscore > s5)
highscore = s5;
return highscore;
}
|