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
|
#include <iostream>
using namespace std;
void sort(double &a, double &b, double &c, double &d, double &e)
{
if (a > b)
{
double tmp = a;
a = b;
b = tmp;
}
if (a > c)
{
double tmp = a;
a = c;
c = tmp;
}
if (a > d)
{
double tmp = a;
a = d;
d = tmp;
}
if (a > e)
{
double tmp = a;
a = e;
e = tmp;
}
if (b > c)
{
double tmp = b;
b = c;
c = tmp;
}
if (b > d)
{
double tmp = b;
b = d;
d = tmp;
}
if (b > e)
{
double tmp = b;
b = e;
e = tmp;
}
if (c > d)
{
double tmp = c;
c = d;
d = tmp;
}
if (c > e)
{
double tmp = c;
c = e;
e = tmp;
}
if (d > e)
{
double tmp = d;
d = e;
e = tmp;
}
return;
}
int main()
{
double ref1, ref2, ref3, ref4, ref5, length, score;
char exit;
do
{
cout << "Enter the length of the jump: ";
cin >> length;
cout << "Ref 1 score: ";
cin >> ref1;
cout << "Ref 2 score: ";
cin >> ref2;
cout << "Ref 3 score: ";
cin >> ref3;
cout << "Ref 4 score: ";
cin >> ref4;
cout << "Ref 5 score: ";
cin >> ref5;
sort(ref1, ref2, ref3, ref4, ref5);
score = (ref2 + ref3 + ref4) / 3;
cout << "Total score for the jump is: " << score + length*0.9 << endl;
cout << "Do you want to run this again? (Y/N):";
cin >> exit;
if (exit == 'y' || exit == 'Y')
system("cls");
} while (exit == 'Y' || exit == 'y');
system("pause");
return 0;
}
|