Hello everyone. I am trying to find the max values of each column in this 5 column array. I have skipped the first column because it is just the product name. The other 4 columns contain revenue of that product. The function I wrote below works for col 1, 2 and 4, but column 3 always shows the same results as column 2. I cannot figure out why. I would appreciate any help you can offer. Thank you in advance.
Here is the function and data file:
void quartprofit(string dis[], double array[][4])
{
int qu;
int row=10;
int col=1;
string dismx;
double mx=0;
for (int a=0;a<4;a++){
for(int i=0;i<row;i++){
for(int qu=0;qu<col;qu++)
if(mx<array[i][qu]) {
mx = array[i][qu];
dismx=dis[i];
}
}
cout << "\n";
cout << col <<" Quarter: "<< dismx << " " << mx << "\n";
col++;
}
}
Data File:
Memory 5 15 7 10
CPU 10 21 0 11
Monitor 2 17 4 42
HD 5 -8 -10 -4
Keyboards 7 10 15 -9
Mice 3 -10 3 10
Drives -1 -11 1 -8
Software 3 5 10 8
Optical 5 7 -8 10
Printers 11 -19 7 3