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
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void totalScore (string[], int[], int[], int[], int[], const int);
void findLowest (string[], int[], const int);
int main()
{
const int ARRAY_SIZE = 5;
string names[ARRAY_SIZE] ;
string lastnames[ARRAY_SIZE];
int score1[ARRAY_SIZE];
int score2[ARRAY_SIZE];
int score3[ARRAY_SIZE];
int score4[ARRAY_SIZE];
int count = 0;
ifstream inputFile;
inputFile.open("BritishOpen2012.txt");
while(count < ARRAY_SIZE)
{
inputFile >> names[count];
inputFile >> lastnames[count];
inputFile >> score1[count];
inputFile >> score2[count];
inputFile >> score3[count];
inputFile >> score4[count];
cout << names[count] ;
cout << lastnames[count]<< endl ;
cout << score1[count]<<endl;
cout << score2[count]<<endl;
cout << score3[count]<<endl;
cout << score4[count]<<endl;
count++;
}
void totalScore(string names[], string lastnames[], int score1[], int score2[], int score3[], int score4[], const int ARRAY_SIZE);
{ int count;
int sum[4];
int lowest =0;
for(count = 0; count < ARRAY_SIZE; count++)
{ sum[count] = score1[count] + score2[count] + score3[count] + score4[count];
cout << names[count] << lastnames[count] << endl << sum[count] <<endl;
}}
void findLowest(string names[], string lastnames[], int sum[], const int ARRAY_SIZE);
int sum[4];
int lowest= sum[0];
for(count=0; count < ARRAY_SIZE; count++)
{if(sum[count]<lowest)
lowest=sum[count];
}
cout << "Lowest score is " << lowest << endl;
//"Player is " <<names[count]<< " " << lastnames[count] <<
system("PAUSE");
return 0;
}
/*
LukeDonald
70
68
71
69
ErnieEls
67
70
68
68
AdamScott
64
67
68
75
BrandtSnedeker
66
64
73
74
TigerWoods
67
67
70
73
LukeDonald
278
ErnieEls
273
AdamScott
274
BrandtSnedeker
277
TigerWoods
277
Lowest score is 273
Press any key to continue . . .
*/
|