fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. void G(int* beg, int* end)
  4. {
  5. int* p = std::max_element(beg, end);
  6. std::cout << "great element " << *p << " great index " << p-beg << '\n';
  7. }
  8. int main()
  9. {
  10. int a[]={4,5,2,12,67,9,0,13};
  11. // G(std::begin(a), std::end(a));
  12. G(a, a+sizeof a/sizeof *a); // ideone's compiler getting old
  13. }
  14.  
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
great element 67 great index 4