1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
using namespace std;
void printarray (int arg[], int length)
//printarray will print the numbers in the array
{
for (int n=0; n<length; n++)
cout << arg[n] << " ";
cout << "\n";
}
int MinimumEntry (int a[], int n)
{
if (n==1) return a[0];
int result = MinimumEntry(a+1, n-1); // note the a+1 and corrected name
if (a[0] < result)
return a[0];
else
return result;
}
int main ()
{
int firstarray[] = {3,2,3,-4,5,6};
int secondarray[]={ 3,2,3,4,5,6};
int thirdarray[]={3,2,3,-4,5,6};
cout<<"First Array is: ";
cout<<endl;
printarray (firstarray,6);
cout<<"Second Array is:";
cout<<endl;
printarray(secondarray,6);
cout<<"Third Array is:";
cout<<endl;
printarray(thirdarray,6);
cout<<endl;
cout<<"sum of First Array =";
cout<<endl;
MininumEntry(firstarray,6);
return 0;
}
|