// This program is to use the bucket sort method to rearrange given numbers.

#include <iostream.h>

#include <fstream.h>

using std::cout;

using std::cin;

using std::endl;

#include <iomanip.h>

using std::setw;

using std::setiosflags;

using std::setpercision;

int main()

{

ifstream infile ( "/u1/rfulk/values");

const int size = 8;

const int a = 10;

int digitCnt, number, num2, z, d, e, f, temp;

z = 0;

digitCnt = 0;

num2 = 0;

number = 0;

d = 0;

e = 0;

f = 0;

int num1[size] = { 0 };

for ( int x = 0; x < size; x++ )

infile >> num1[x];

for ( int x = 0; x < size; x++ )

{

if ( num1[x] != 0 )

{

cout << "Look, here's value " << x << ": " << num1[x] << endl;

z++;

}

}

cout << z << endl;

int num3[a][z];

for ( int x = 0; x < a; x++ )

{

for ( int y = 0; y < z; y++ )

num3[x][y] = 0;

}

for ( int x = 0; x < z; x++ )

{

number = num1[x];

e = d;

digitCnt = 0;

while(number)

{

number=number/10;

digitCnt++;

}

d = digitCnt;

if ( e > d )

f = d;

}

int u;

int b = 10;

int c = 1;

for ( int w = 1; w <= 8; w++ )

{

u = 0;

for ( int x = 0; x < z; x++ )

{

num2=num1[x]%b/c;

num3[num2][x] = num1[x];

}

for ( int x = 0; x < 10; x++ )

{

for ( int y = 0; y < 6; y++ )

{

if ( num3[x][y] != 0 )

{

num1[u] = num3[x][y];

u++;

}

}

}

c = c * 10;

b = b * 10;

cout << "Here is your numbers sorted through sort #" << w << endl;

for ( int x = 0; x < z; x++ )

cout << setw(10) << num1[x];

cout << endl;

}

return 0;

}

Ok here is the problem. The program compiles, then I run it, it goes through 2 loops and then dumps the last number and jumps out with a segmintation fault. Does anyone have a soultion to remeady this problem?