Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int Minv(int A[], int n)
- {
- if (n == 1)
- return A[0];
- return min(A[n-1], Minv(A, n-1));
- }
- int Maxv(int A[], int n)
- {
- // if n = 0 means whole array has been traversed
- if (n == 1)
- return A[0];
- return max(A[n-1], Maxv(A, n-1));
- }
- int main()
- {
- int A[] = {1, 4, 45, 6, -50, 10, 2};
- int n = sizeof(A)/sizeof(A[0]);
- cout << "Your Aray's Max value is: " << Maxv(A, n) << endl;
- cout << "Your Aray's Max value is: " << Minv(A, n) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement