I am given a data file that contains sports data for 24 people. There are two rounds of the event. The first 48 lines of the file give the data for the 1st round and the second 48 lines give data for the 2nd round. The file looks like this:
Azrin, Neil 2.3 6.0 5.0 6.7 7.8 5.6 8.9 7.6
Babbage, Charles 2.3 5.6 6.5 7.6 8.7 7.8 5.4 4.5
Burks, Arthur 2.8 4.5 5.4 6.6 7.7 8.8 5.6 6.5
Crick, Francis 1.6 6.5 6.5 6.5 7.3 7.5 7.8 5.6
Curie, Marie 2.9 9.4 9.5 9.2 8.0 5.6 9.0 9.8
Dale, Nell 1.0 2.3 2.3 2.3 2.3 3.4 3.4 3.4
Einstein, Albert 1.5 5.0 5.0 5.0 5.0 5.0 5.0 5.0
Franklin, Rosalyn 2.0 7.8 7.8 7.6 7.5 8.0 6.7 7.6
Heisenberg, Werner 2.2 8.2 8.1 8.0 8.5 8.6 8.3 9.0
Hofstadter, Douglas 1.8 9.3 9.0 9.2 8.4 7.8 8.0 5.6
Krieger, Dorothy 3.0 7.6 7.8 8.7 5.9 6.4 7.1 8.0
Mead, Margaret 2.7 8.0 8.0 7.8 6.5 7.4 8.2 5.9
Minsky, Marvin 2.7 7.8 6.8 7.1 7.4 5.6 4.9 5.7
Newton, Isaac 2.3 9.0 9.1 9.0 9.2 9.2 9.0 8.9
Olsen, Catherine 2.6 7.8 9.1 8.4 8.4 8.2 8.4 7.6
Pascal, Blaise 3.0 4.5 6.4 8.0 5.6 7.5 6.5 8.0
Pylyshyn, Zenon 2.8 8.6 7.9 9.0 6.9 7.3 6.9 7.0
Sagan, Carl 2.5 7.8 9.0 8.7 8.6 4.6 7.6 8.0
Schroedinger, Erwin 2.7 8.0 7.8 8.0 9.0 6.7 8.7 6.5
Turing, Alan 2.5 7.8 8.0 8.0 7.9 7.3 7.6 7.6
Van Allen, James 2.7 6.9 7.0 7.0 7.2 6.7 7.0 8.0
Von Neumann, John 3.0 7.8 8.9 9.0 8.7 9.0 7.9 9.2
Watson, James 2.8 9.6 9.7 9.7 9.0 9.5 9.7 9.0
Weems, Chip 2.5 7.8 7.8 7.6 7.5 7.8 8.0 6.7
Azrin, Neil 2.1 6.0 5.0 6.5 7.8 5.6 8.8 7.6
Babbage, Charles 2.3 5.4 6.5 7.6 8.7 7.2 5.4 5.5
Burks, Arthur 2.7 4.1 5.4 5.6 7.8 8.2 5.6 6.5
Crick, Francis 1.5 7.5 6.4 6.5 7.2 7.5 7.5 6.6
Curie, Marie 2.8 9.5 9.1 9.2 8.4 5.6 9.3 9.7
Dale, Nell 2.0 3.3 3.3 3.3 2.3 3.1 3.0 4.4
Einstein, Albert 2.5 5.1 5.2 5.3 5.4 5.5 5.6 5.7
Franklin, Rosalyn 3.0 7.8 7.7 7.1 7.5 8.2 6.7 7.6
Heisenberg, Werner 2.5 8.2 8.4 8.0 8.7 8.7 8.1 9.0
Hofstadter, Douglas 2.8 9.1 9.0 9.1 8.4 6.8 8.0 6.6
Krieger, Dorothy 3.0 7.4 7.1 7.7 6.9 6.4 7.1 8.0
Mead, Margaret 2.8 8.1 8.0 7.1 6.5 6.4 8.2 5.9
Minsky, Marvin 2.1 7.8 7.8 7.1 7.4 7.6 5.9 5.7
Newton, Isaac 2.3 8.0 9.0 9.0 9.2 8.2 9.0 8.9
Olsen, Catherine 2.0 6.8 9.1 8.4 8.0 8.2 8.4 7.6
Pascal, Blaise 3.0 5.5 6.4 8.1 5.6 7.4 6.5 7.0
Pylyshyn, Zenon 2.7 8.6 6.9 9.0 6.5 7.3 8.9 7.0
Sagan, Carl 3.0 6.8 9.0 8.2 8.6 5.6 7.6 8.0
Schroedinger, Erwin 1.7 8.0 6.8 8.5 9.0 7.7 8.7 6.5
Turing, Alan 2.4 7.7 8.1 8.2 7.3 7.3 7.6 7.6
Van Allen, James 2.7 7.9 7.0 6.0 7.2 8.7 7.0 8.0
Von Neumann, John 3.0 7.1 8.9 9.0 7.7 9.0 8.9 9.2
Watson, James 2.1 8.6 9.8 9.8 9.0 9.1 9.7 9.0
Weems, Chip 2.7 6.8 7.3 7.6 6.5 7.8 8.0 6.2
This data continues for all 24 people and then repeats with different score values for the second round. The first number after the persons name is the level of difficulty and then next 7 numbers are the scores. I am trying to get this data out of the file and set it up in the following format:
Name Of Person Round 1: level of difficulty scores Round 2: level of difficulty scores
So the table for the above data would look something like this:
Arzin, Neil
Round 1: 2.3 6.0 5.0 6.7 7.8 5.6 8.9 7.6
Round 2: 2.1 6.0 5.0 6.5 7.8 5.6 8.8 7.6
Babbage, Charles
Round 1: 2.3 5.6 6.5 7.6 8.7 7.8 5.4 4.5
Round 2: 2.3 5.4 6.5 7.6 8.7 7.2 5.4 5.5
And so on for all 24 people. This is the code I have for it, but it just reads the file directly:
// I have already opened the file!
while (inFile)
{
string name;
getline(inFile,name);
cout << name << endl;
}
Could anyone provide some insight as to how I can do some sort of formatting on this data?
EDIT
I was given the following data structures to use
const int numRounds = 2;
const int numScores = 7;
const int numDivers = 24;
// 1D array for storing difficulty of dives on each round
typedef double DifficultyList[numRounds];
// 2D array of dive scores
typedef double ScoreTable[numRounds][numScores];
// struct to store info for one diver
struct DiverRecord
{
string name; // persons name
double totalScore, // total score for both rounds
diveTotal; // total on current round
DifficultyList diff; // difficulty on all dives (1X2 array)
ScoreTable scores; // scores for all rounds (2X7 array)
};
// array of structs of diver records
typedef DiverRecord DiverList [numDivers];
Thank you!