//Tests the divide and conquer sorting pattern. #include using std::cout; using std::cin; using std::endl; #include "sortpattern.cpp" #include "quicksort.cpp" void fillArray(int a[], int size, int& numberUsed); //Precondition: size is the declared size of the array a. //Postcondition: numberUsed is the number of values stored in a. //a[0] through a[numberUsed - 1] have been filled with //nonnegative integers read from the keyboard. int main( ) { cout << "This program sorts numbers from lowest to highest.\n"; int sampleArray[10], numberUsed; fillArray(sampleArray, 10, numberUsed); sort(sampleArray, numberUsed); cout << "In sorted order the numbers are:\n"; for (int index = 0; index < numberUsed; index++) cout << sampleArray[index] << " "; cout << endl; return 0; } void fillArray(int a[], int size, int& numberUsed) { cout << "Enter up to " << size << " nonnegative whole numbers.\n" << "Mark the end of the list with a negative number.\n"; int next, index = 0; cin >> next; while ((next >= 0) && (index < size)) { a[index] = next; index++; cin >> next; } numberUsed = index; }