So this is the question's I've recieved.
a) Place each value of the one-dimensional array into a row of the bucket array based on the value's ones digit. For example, 97 is placed in row 7, 3 is placed in row 3, and 100 is placed in row 0. This is called a "distribution pass."

Loop through the bucket array row by row, and copy the values back to the original array. This is called a "gathering pass." The new order of the preceding values in the one-dimensional array is 100, 3, and 97.
c) Repeat this process for each subsequent digit position.
I'm no sure if I understand what I'm doing too well, but my code doesn't quite do what I'm trying to do.
Also the error I receive is 0xC0000005 after the program terminates.#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int sort(int arrNum[], int arrSize)
{
const int max = arrSize;
int bucket[10][max+1];
for(int x = 0;x < 10; x++) bucket[x][max] = 0;
for(int digit = 1; digit <= 10000000; digit *= 10)
{
for(int i = 0; i < max; i++)
{
int digit2 = (arrNum[i] / digit) % 10;
bucket[digit2][bucket[digit2][max]++] = arrNum[i];
}
int j = 0;
for(int x = 0; x < 10; x++)
{
for(int y = 0; y < bucket[x][max]; y++)
{
arrNum[j++] = bucket[x][y];
bucket[x][max] = 0;
}
}
}
return 0;
}
int main()
{
int i;
cout << "Input array size: ";
int size;
cin >> size;
cout << endl;
int* array = new int [size];
delete[] array;
srand((unsigned)time(0));
for(i = 0; i < size; i++)
{
array[i] = (rand()%100)+1;
cout << array[i] << " ";
}
cout << endl << "Sorting Array: " << endl;
for (i = 0; i <= size; i++)
{
sort(array,size);
cout << array[i] << " ";
}
}
This post was edited by sylz1014 on Jan 21 2013 03:42pm