fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int divideEtConquer(int vec[], int left, int right) {
  5. int m;
  6. if(left == right) {
  7. return vec[ left ];
  8. } else {
  9. int a, b;
  10. m = (left + right)>>1;
  11. a = divideEtConquer(vec, left, m);
  12. b = divideEtConquer(vec, m + 1, right);
  13. if(a < b) return a;
  14. else
  15. return b;
  16. }
  17. }
  18.  
  19. int main(int argc, char const *argv[]) {
  20.  
  21. int vec[] = {44,22,99,100,101,-19,17,0,1,2,3},
  22. n = sizeof(vec)/sizeof(vec[0]),
  23. max;
  24. max = divideEtConquer(vec, 0, n - 1);
  25. cout<<max;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 5384KB
stdin
Standard input is empty
stdout
-19