fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int mul(int * arr, int shift, int N)
  6. {
  7. switch (N)
  8. {
  9. case 1:
  10. return arr[shift];
  11. break;
  12.  
  13. case 2:
  14. return (arr[shift] * arr[shift + 1]);
  15. break;
  16.  
  17. default:
  18. int M = N / 2;
  19. return (mul(arr, shift, M) * mul(arr, shift + M, N - M));
  20. }
  21. }
  22.  
  23. int main()
  24. {
  25. int array[] = {5, 4, 3, 2, 1};
  26.  
  27. cout << mul(array, 0, 5) << endl;
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 4388KB
stdin
Standard input is empty
stdout
120