0
int Min[m];
for(int i=0; i<m;i++){
    int Min_Element=INT_MAX;
    for(int j=0;j<n;j++){
        Min_Element = min ( Min_Element , Target[i][j]);
    }
    Min[i]=Min_Element;
}

Can someone tell me the whole explaination about the algorithm above to me please..

I still can't figure out the detail about how the Min_Element = min ( Min_Element , Target[i][j]); works..

EL pasta
  • 15
  • 3
  • 1
    Have you tried running this code in a debugger or other visualization tool to see its logic step-by-step? Or, alternatively, have you tried manually "running" the code with pen and paper with a plausible set of inputs in order to better understand it? – nanofarad Nov 11 '20 at 05:17
  • 1
    `int Min[m];` might not be valid C++ if [`m` is a variable](https://stackoverflow.com/a/15013295/1270789). – Ken Y-N Nov 11 '20 at 05:20

2 Answers2

0

It looks for the minimal element of each row (indexed by i) by comparing each column of a matrix (target[i][j]) to a temporary minimal value (initialized with a very large number to make sure it gets discarded by values stored in the matrix).

Gabriel
  • 106
  • 4
0

This may help

int Min[m];  // store minimum value for each row
for(int i=0; i<m;i++){  // loop each row
    int Min_Element=INT_MAX; // start at max value
    for(int j=0;j<n;j++){  // for each number in row
        Min_Element = min ( Min_Element , Target[i][j]);  // set minimum value if less than current minimum
    }
    Min[i]=Min_Element;  // minimum value for row
}
Mike67
  • 11,175
  • 2
  • 7
  • 15