I've been trying to get this to compile but I've been unsuccesful:
Code:#include<iostream> using namespace std; #define MAX_LIST_LEN 100 int main(){ int n, // list length j, // loop control i, // index of maximum element in unsorted section R; // index of rightmost element in unsorted section double max, // maximum value in unsorted section temp, // temporary storage list[MAX_LIST_LEN]; // array to be sorted // Get values for n and list. cout << "Enter list length (must be less than or equal to " << MAX_LIST_LEN << "): "; cin >> n; cout << "Enter " << n << " numbers:" << endl; for(j=0; j<n; j++){ cin >> list[j]; } (int array[], int n){ for (int L = 1; L < n; L++){ int j = L; int B = array[L]; while ((j > 0) && (array[j-1] > B)){ array[j] = array[j-1]; j--; } array[j] = B; } } // Print out sorted list. for(j=0; j<n; j++){ cout << list[j] << " "; } cout << endl; return(0); }




Reply With Quote