How to use max_element in C++

1 Answer

0 votes
#include <iostream> 
#include <algorithm> 

int main()  { 
    int arr[] = { 'a', 'x', 'y', 'b', 'd', 'c', 'v', 'e' }; 
  
    int *p = std::max_element(arr, arr +  sizeof(arr)/sizeof(arr[0])); 
  
    std::cout << char(*p);
    
    return 0; 
} 



/*
run:

y

*/

 



answered Jan 3, 2021 by avibootz

Related questions

1 answer 131 views
131 views asked Jul 20, 2024 by avibootz
...