There are numerous algorithms that allow you to
manipulate the information stored in an array. Consider this
function which allows you to determine the maximum value in an array of
integers (could be easily adapted to find minimum value):
//Function to find highest (maximum) value
in array
int maximumValue(apvector<int> &array)
{
int length = array.length( );
// establish size of array
int max = array[0]; // start with max = first
element
for(int i = 1; i<length; i++)
{
if(array[i] > max)
max = array[i];
}
return max;
// return highest value in array
} |