|
| |||||||||||||||||||||||||||||||||||||||
| nadir CoCo (20) | |
|
hello everybody, can anyone tell me how to use "max_element" of the STL algorithm for finding the maximum in each line of a matrix (2D array) of doubles? thank you | |
|
|
|
| hamsterman (4538) | |
max_element(my_matrix+i*N, my_matrix+(i+1)*N); should return the max element of i'th row. This won't work for columns.
| |
|
|
|
| vlad from moscow (4921) | |||
|
std::max_element returns an iterator that points to the maximum element. The general invoking of it looks like std::max_element( std::begin( conteiner ), std::end( container ) ); where container is any arbitrary standard container or an array. Let assume that you have a two-dimensional array and you need to print the maximum element in every row of the array. You can use in this case two standard algorithms together.
I did not test the code but I hope it will work. | |||
|
Last edited on
|
|||
| nadir CoCo (20) | |
| Thanks ;) | |
|
|
|