void Selection_Sort(int SUM_1[], int n){
int Lid, tmp;
for (int i = 0; i < n - 1; i++){
Lid = i;
for (int j = i + 1; j < n; j++){
if (SUM_1[j] != 0 && SUM_1[Lid] != 0 && SUM_1[j] < SUM_1[Lid]){
Lid = j;
}
tmp = SUM_1[i]; SUM_1[i] = SUM_1[Lid]; SUM_1[Lid] = tmp;
}
}
}
The reason why I wrote the above code is,
the array SUM_1[] is something like this, {0, 1, 0, 3, 0, 5, 6},
but the result I wanted after going through Selection_Sort is {1, 3, 5, 6, 0, 0, 0}. not {0, 0, 0, 1, 3, 5, 6}.
I seems that I did it wrong.
Can anyone please help me correct my Selection_Sort code to get the outcome that I want??