Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/06/08 17:47
Read: times


 
#156432 - Yes I saw the corruption...
Responding to: ???'s previous message
and I modified it as you mention, I believe I did as you mentioned since it did sort, and it did come out of the loop. I switch all the unsigned chars to ints, but that still leaves me in a bit of a jam, I need to find a way to sort an array of bytes only. I will be using it for a median sort and ints complicate the process. Is there a suggestion to help me rewrite this properly? Thanks for the Sunday responses folks....I know your time is valuable.

Here is the modified code:
void bubbleSort(int my_array[], int array_size); //prototype

int zoom_array[5] = {9,4,2,8,3}; //my array initialized out of order

void bubbleSort(int my_array[], int array_size) //sort it
{
  int i, j, temp;

  for (i = (array_size - 1); i >= 0; i--)
  {
    for (j = 1; j <= i; j++)
    {
      if (my_array[j-1] > my_array[j])
      {
        temp = my_array[j-1];
        my_array[j-1] = my_array[j];
        my_array[j] = temp;
      }}}}

void main (void)//main program
{
										  
while(1)//Loop this section forever
   {  
     bubbleSort(zoom_array, 5); //sort forever test
   }
}


List of 9 messages in thread
TopicAuthorDate
Compile error using a bubble sort            01/01/70 00:00      
   Is the array 'uchar' or is it 'int'? Do not mix.            01/01/70 00:00      
   argument consistency            01/01/70 00:00      
      I had one error and type mismatch seen            01/01/70 00:00      
         more careful with decrement unsigned char            01/01/70 00:00      
         Use different identifiers for global and auto            01/01/70 00:00      
            Yes I saw the corruption...            01/01/70 00:00      
               You can use any type you like.            01/01/70 00:00      
                  thanks guys....            01/01/70 00:00      

Back to Subject List