I was informed by a couple of folks to look into C++ Vectors. That turned out to be grand advice so I'd like to share the code that I came up with:
void zeroOnlyBubbleSort(vector< vector >&passedArray ){
for(int y = 0; y < passedArray.size(); y++){
bool needNextPass = true;
while (needNextPass == true){
needNextPass = false;
for(int x = 1 ; x < passedArray.size() ; x++) {
if (passedArray[x][y] == 0 && passedArray[x-1][y] != 0){
int temp = passedArray[x][y];
passedArray[x][y] = passedArray[x-1][y];
passedArray[x-1][y]= temp;
needNextPass = true;
}
}
}
}
}
No comments:
Post a Comment