I was told to use bubble sort to sort the arrays. what i need to do is read in one array and have to sort into the other array but i haven't been able to figure it out here's the code i have so far. i've been trying to manuplate many different ways and research online, but i haven't been able to figure it out.
void Sort(const double inputArray[], double outputArray[], int inputLengthOfList)
{
//Local Variables
int pass;
int i;
double hold;
/* bubble sort */
/* loop to control number of passes */
for ( pass = 1; pass < inputLengthOfList; pass++ )
{
/* loop to control number of comparisons per pass */
for ( i = 0; i < inputLengthOfList - 1; i++ )
{
/* compare adjacent elements and swap them if first
element is greater than second element */
if ( inputArray[ i ] > inputArray[ i + 1 ] )
{
hold = inputArray[ i ];
outputArray[ i ] = inputArray[ i + 1 ];
outputArray[ i + 1 ] = hold;
} /* end if */
} /* end inner for */
} /* end outer for */
}// end function Sort
Any suggestion or examples would be greatly appreaiated.
Thanks
zingwing