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
|
#include <iostream>
void findscore(int&, int&, int&, int&, int&);
void findsum(int&, int&, int&, int&, int&);
int findlowest(int, int, int, int, int);
int findhighest(int, int, int, int, int);
using namespace std;
int main()
{
int s1, s2, s3, s4, s5, lowest, highest, sum;
findscore(s1, s2, s3, s4, s5);
findsum(s1, s2, s3, s4, s5);
}
void findscore(int& s1, int& s2, int& s3, int& s4, int& s5)
{
cin >> s1;
cin >> s2;
cin >> s3;
cin >> s4;
cin >> s5;
}
int findlowest(int, int, int, int, int)
{
int s1, s2, s3, s4, s5, lowest;
findscore(s1, s2, s3, s4, s5);
lowest = s1;
if (lowest > s2)
{
lowest = s2;
}
if (lowest > s3)
{
lowest = s3;
}
if (lowest > s4)
{
lowest = s4;
}
if (lowest > s5)
{
lowest = s5;
}
return lowest;
}
int findhighest(int, int, int, int, int)
{
int s1, s2, s3, s4, s5, highest;
findscore(s1, s2, s3, s4, s5);
highest = s1;
if (highest < s2)
{
highest = s2;
}
if (highest < s3)
{
highest = s3;
}
if (highest < s4)
{
highest = s4;
}
if (highest < s5)
{
highest = s5;
}
return highest;
}
void findsum(int& s1, int& s2, int& s3, int& s4, int& s5)
{
int lowest;
int highest;
int sum;
lowest = findlowest(s1, s2, s3, s4, s5);
highest = findhighest(s1, s2, s3, s4, s5);
sum = (s1+s2+s3+s4+s5-lowest-highest);
cout << sum;
}
|