So right now my program is simply storing the lowest values I input SIZE number of times, can someone help me out with this? I thought that testing the values against 'final' would fix this.
int least_to_greatest(int *scores){
int least_to_greatest[SIZE], a, b, c, n, low = 101, duplicate = 0, final = 0;
for (a = 0; a < SIZE; a++){ //assign low values to least_to_greatest[a]
for (b = 0; b < SIZE; b++){ //chose low values of score
if (scores[b] == low){ //deals with duplicates
duplicate++;
}
if (scores[b] < low && scores[b] > final){ //assigns new lowest value to low as long as it's larger than previous low value
low = scores[b];
duplicate = 0;
}
}
final = low; //final low value
least_to_greatest[a] = final;
if (duplicate > 0){ //deals with duplicates
for (c = 0; c < duplicate; c++){
a++;
least_to_greatest[a] = final;
}
}
}
for (n = 0; n < SIZE; n++){
if (!(n % 5)){
printf("\n"); //creates a newline after 5 values
}
printf("%d ", least_to_greatest[n]); //prints scores in least to greatest
}
getchar();
}
currentEntryCountto1copying the value fromb-1. When you find a value withresult[b-1]less than your new entry stop.