#include using namespace std; /* find_max * Parameters: array of integers, length of array * Return value: maximum value from the array * Note: size_t is a 64-bit unsigned integer on most platforms today. You can * treat it like any other integer type. */ int find_max(int array[], size_t length){ // TODO: Finish this function } /* reverse * Parameters: array of integers, length of array * Return value: None (will modify the array argument) * Note here that arrays are passed by reference in C++, so your changes * will affect the array declared in main. */ void reverse(int array[], size_t length){ // TODO: Finish this function } /* is_ordered * Parameters: array of integers, length of array * Return value: boolean indicating whether the array is in order * from least to greatest. */ bool is_ordered(int array[], size_t length){ // TODO: Finish this function } void print_array(int array[], size_t length){ for(int i = 0; i < length; i++) cout << array[i] << " "; cout << "\n"; } int small_random(){ return random() % 100; } /* You don't need to change anything in main for lab 5. */ int main(){ int array_one[] = {3, 6, 9, 12, 15}; int array_two[10]; /* In this context, int& i means i is a reference to an int. * So when we change it, we're changing the actual array. If you * leave it off, the array won't actually be changed. References * are coming starting next week with pointers. */ for(int& i : array_two) i = small_random(); print_array(array_one, 5); print_array(array_two, 6); cout << "Array one max: " << find_max(array_one, 5) << endl; cout << "Array two max: " << find_max(array_two, 6) << endl; if(is_ordered(array_one, 5)) cout << "Array one is ordered\n"; else cout << "Array one is NOT ordered\n"; if(is_ordered(array_two, 5)) cout << "Array two is ordered\n"; else cout << "Array two is NOT ordered\n"; reverse(array_one, 5); cout << "Array one, reversed: "; print_array(array_one, 5); reverse(array_two, 4); cout << "Array two, first 4 numbers reversed: "; print_array(array_two, 6); return 0; }