Well, in order to try to understand this, I worked through the entire problem, including sorting, calculation, report headings and output of results.
I had to guess at what headings and what results were supposed to be output. Usually one has to navigate a path from the input of data to the output of something, but I'm not clear on what outputs are required.
I still feel I may not be following everything, even having got through to the end.
My approach was like this. I used a structure in order to hold the information for a single person. That looks like this:
1 2 3 4 5 6 7 8
|
struct Subject {
int id;
int max_hr;
int age;
double avg_com_hr[MAX];
double max_com_hr[MAX];
double exercise_hr[MAX];
};
| |
Then I created an array of those objects, and read the information from the file into that array.
My main() now contains code like this:
1 2 3 4 5
|
ifstream inputfile("HR.txt");
Subject data[SIZE];
int count = getdata(inputfile, data);
| |
where I defined SIZE as
Then the array
data[SIZE]
is the first of the six arrays. The other five arrays correspond to the five values which are to be calculated.
That gives, as specified,
Use precisely six parallel arrays: one for subject numbers and five for the calculated values as described below. |
Sorry if this seems out of step with some of what you have been asked to do.