fork download
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. int main() {
  5. using namespace std;
  6.  
  7. int i[] = { 1, 84, 11, 31 };
  8. cout << *std::max_element(i, i + (sizeof(i) / sizeof(*i))) << endl; // for C++03 or earlier
  9.  
  10. // C++11 and later:
  11. cout << *std::max_element(std::begin(i), std::end(i)) << endl;
  12. auto i2 = { 1, 84, 11, 31 };
  13. cout << std::max(i2) << endl;
  14. cout << std::max({ 1, 84, 11, 31 }) << endl;
  15. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
84
84
84
84