I have an array and I want to get the max value and its index. I’m using this code:
#include <iostream>
#include <algorithm> //max-element
using namespace std;
#define J 5
int main(int argc, char** argv)
...
double ucolumn[J]={};
for(j=0;j<J;j++)
for(i=0;i<I;i++)
ucolumn[j]+=u[i][j];
double q=*max_element(ucolumn[0],ucolumn[J]) << endl;
return 0;
}
but it gives me an error of “illegal indirection”, “mismatch in formal parameter list”
You need to use the algoritm with iterator rather than valies: