fork download
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. int main()
  5. {
  6. float array[3][2] = { { 16, 22 }, { 258, 1 }, { 42, 54 } };
  7.  
  8. auto it = std::max_element(std::begin(array), std::end(array),
  9. [](const auto& lhs, const auto& rhs) { return lhs[1] < rhs[1]; });
  10.  
  11. std::cout << "The maximum value in the array is " << (*it)[1] << std::endl;
  12. std::cout << "other element in the array is " << (*it)[0] << std::endl;
  13. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
The maximum value in the array is 54
other element in the array is 42