Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- unsigned int maxModRecurs(int *inArr, unsigned int size);
- int main() {
- int arr[] = {1, 14, 99, 22, -11, -55, 0};
- cout << "maxMod = " << maxModRecurs(arr, sizeof(arr)/sizeof(int)) << endl;
- return 0;
- }
- unsigned int maxModRecurs(int *inArr, unsigned int size) {
- if (size == 1)
- return abs(*inArr);
- return max((unsigned int)abs(inArr[size - 1]), maxModRecurs(inArr, size - 1));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement