In the book im studing it shows you how to bubble sort a single subscripted array. I see nothing on doing that with a double subscripted array. So I have just been messing with it to see and I cant get it sort the array. Here's the code.
Im not at the level of vectors and such. I run this on the array and it moves some of them but it doesnt put them in the proper order.Code:void bubbleSort(int c[][5]) { int hold; for ( int i = 0; i < 3; i++ ) for ( int j = 0; j < 5 - 1; j++ ) if( c[i][j] > c[i][ j + 1 ] ) { hold = c[i][j]; c[i][j] = c[i][ j + 1 ]; c[i][ j + 1 ] = hold; } for( int k = 0; k < 3; k++ ) { for( int l = 0; l < 5; l++ ) cout << c[k][l] << ' ' ; } }



LinkBack URL
About LinkBacks


