Help me Solve this problem
I have an array(size 35) with various positive double values. I need to use these values in an algorithm ultimately to calculate an (x,y) position on a graph, but that is irrelevant. What I need help with is how to narrow this array down from 35 values to 20. You see, the 35 values range (from around 40 to 80...usually) and what I want to do, is get my array of 35 (all the values) to become a smaller array of 20 that is made up of the 20 highest values from the array of 35. I have been working on this algorithm the past 3 hours and am getting kind of sick of it, so any hints or help from you guys would be appreciated.
Here is basically what I have so far.
Code:
for( i=0; i+1<=35; i++ )
{
GetVal ( dRSSI[i] ); // I fill my array of 35 w/ values i need
}
for( i=0, n=0; i+1<=35, n+1<=20; i++, n++ )
{
if( dRSSI[i] >= dRSSI[i+1] ) //If val a > b, keep a and put it into smaller
{ //array
LessdRSSI[n] = dRSSI[i];
}
}