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
|
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
void GetScores(string firstNames[], string lastNames[], double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[]);
void PrintScores(string firstNames[], string lastNames[], double totalScore[]);
double getMin(double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[]);
double getMax(double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[]);
void getSum(double totalScore[], double min, double max);
int main()
{
string firstNames[5];
string lastNames[5];
double Score1[5];
double Score2[5];
double Score3[5];
double Score4[5];
double Score5[5];
double Score6[5];
double Score7[5];
double Score8[5];
double totalScore[5];
GetScores(firstNames, lastNames, Score1, Score2, Score3, Score4, Score5, Score6, Score7, Score8);
int i = 0;
for (int i = 0; i < 5 ; i++)
{
double min = getMin(Score1[i], Score2[i], Score3[i], Score4[i], Score5[i], Score6[i], Score7[i], Score8[i]);
double max = getMax(Score1[i], Score2[i], Score3[i], Score4[i], Score5[i], Score6[i], Score7[i], Score8[i]);
getSum(min, max, totalScore[i]);
}
PrintScores(firstNames, lastNames, totalScore);
return 0;
}
void GetScores(string firstNames[], string lastNames[], double Score1[], double Score2[], double Score3[], double Score4[], double Score5[], double Score6[], double Score7[], double Score8[])
{
ifstream infile;
infile.open("gym.txt");
int i = 0;
for (i = 0; i < 5 ; i++)
infile >> firstNames[i] >> lastNames[i] >> Score1[i] >> Score2[i] >> Score3[i] >> Score4[i] >> Score5[i] >> Score6[i] >> Score7[i] >> Score8[i] ;
infile.close();
}
void PrintScores(string firstNames[], string lastNames[], double totalScore[])
{
}
double getMax(double Score1, double Score2, double Score3, double Score4, double Score5, double Score6, double Score7, double Score8)
{
double max = Score1;
if (max < Score2)
max = Score2;
if (max < Score3)
max = Score3;
if (max < Score4)
max = Score4;
if (max < Score5)
max = Score5;
if (max < Score6)
max = Score6;
if (max < Score7)
max = Score7;
if (max < Score8)
max = Score8;
return max;
}
double getMin(double Score1, double Score2, double Score3, double Score4, double Score5, double Score6, double Score7, double Score8)
{
double min = Score1;
if (min < Score2)
min = Score2;
if (min < Score3)
min = Score3;
if (min < Score4)
min = Score4;
if (min < Score5)
min = Score5;
if (min < Score6)
min = Score6;
if (min < Score7)
min = Score7;
if (min < Score8)
min = Score8;
return min;
}
void getSum(double min, double max, double totalScore[])
{
int i= 0;
for (int i = 0; i < 5 ; i++)
totalScore[i] = totalScore[i] - min - max;
}
|