sorting values generated in a loop
Posted on 2003-02-26
i am trying to get values (n number of values, determined by the user) that will be controlled in a FOR loop
"for (counter = 1; counter <= n; counter++)
printf(" Enter a score: ");
sum += score;
average = (float)sum/n;"
I will have -1 values to mean n/a score. if there are two or more -1's then do not calculate the average (and dont print it)
for instance, if n=4, the program should take the best three to calculate the average i.e. drop the least(smallest) value.
i am dont have the faintest idea on how to sort these values and be able to drop the least value.
programming skills is quiet basic, nothing really fancy (probably simple if statements) although i will be more than happy to encounter new stuff.
Any help is appreciated. Thanks