// pseudo-code
void findElements( int array[], size_t numElems ) {
for( elements 1 through numElems - 1 )
if( array[ element ] < array[ 0 ] )
copy array[ element ] to a new array
// Now the new array will have only the elements smaller
// than array[ 0 ].
}
Another way to do it (in one line of code):
1 2 3 4 5 6
#include <algorithm>
int array[ ARRAY_SIZE ]; // Assume this is the array of elements
// This will make elements [1] - [9] the smallest values in the array.
std::partial_sort( &array[ 1 ], &array[ 9], &array[ ARRAY_SIZE ] );
well, depends on what you want. do you want the 8 SMALLEST numbers that is smaller than the first element?
for example, if you array is {10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ....} do you want the smallest 8 number smaller than 10, meaning (0, 1, 2, 3, 4, 5, 6, 7) or is something like ( 0, 1, 2, 3, 4, 5, 8, 9) also ok?