// FILE: DblMinDr.cpp // DRIVER FOR FUNCTION "find_index_of_min" #include #include "apvector.h" #define SIZE 5 #include "FloatMin.cpp" // Functions Used... // FIND THE INDEX OF THE SMALLEST VALUE IN A FLOATING POINT SUBARRAY // CONSISTING OF ELEMENTS x[start_index] THROUGH x[end_index] int find_index_of_min (const apvector &, // IN: array of elements int, // IN: subscript of first element int); // IN: subscript of last element // driver (not included in the text) int main () { // Local Data... apvector a(SIZE); int start_index; int end_index; int min_index; // read in array a cout << endl << "Enter " << SIZE << " numbers seperated by a space> " << endl; for (int i = 0; i < SIZE; i++) cin >> a[i]; // read in the start index of the substring cout << "Enter the starting index of the array substring (between 0 and " << (SIZE-1) << ") > "; cin >> start_index; // read in the end index of the substring cout << "Enter the ending index of the array substring (between " << start_index << " and " << (SIZE-1) << ") > "; cin >> end_index; // find the minimum in the array substring min_index = find_index_of_min(a, start_index, end_index); //print out the minimum element cout.setf(ios::fixed); if (min_index != -1) cout << endl << "The minimum element in the substring is " << a[min_index] << endl; else cout << endl << "Subarray is out of bounds." << endl; return 0; }