Advertisement
SteelK

Untitled

Jun 16th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. unsigned int maxModRecurs(int *inArr, unsigned int size);
  7.  
  8. int main() {
  9.     int arr[] = {1, 14, 99, 22, -11, -55, 0};
  10.     cout << "maxMod = " << maxModRecurs(arr, sizeof(arr)/sizeof(int)) << endl;
  11.     return 0;
  12. }
  13.  
  14. unsigned int maxModRecurs(int *inArr, unsigned int size) {
  15.     if (size == 1)
  16.         return abs(*inArr);
  17.     return max((unsigned int)abs(inArr[size - 1]), maxModRecurs(inArr, size - 1));
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement