fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. int tab[] = {1,2,3,4,3,2,1};
  7. auto max = std::max_element(tab, tab+7);
  8. std::cout << *max << std::endl
  9. << "pos: " << std::distance(tab,max) << std::endl;
  10. return 0;
  11. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
4
pos: 3