fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int maxarray(const int a[], int first, int last) {
  6. if (first+1 == last) {
  7. return a[first];
  8. }
  9. int mid = first + (last - first) / 2;
  10. int left = maxarray(a, first, mid);
  11. int right = maxarray(a, mid, last);
  12. return left > right ? left : right;
  13. }
  14.  
  15. int main() {
  16. int arr[10] = {1,20,3,41,5,6,7,8,99,0};
  17. cout << maxarray(arr, 0, 10) << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
99