0

Hey all, back once again. I've got some more code that i need some help with. Thanks to Aia for his help as well. Anywho this time I've still got the fifty random integers and now I'm working on sorts. I've managed to complete the bubblesort portion of the book but the Qsort is still giving me a bit of an issue. Basically i need to take what i have, print the fifty randoms, sort them and then print them once sorted. Any help as usual would be greatly appreciated.

#include <stdio.h>
      #include <stdlib.h>
      #include <time.h>
      int main( void )
      {
      int fifty[50];
      int i;
      srand( (unsigned ) time( NULL ) );
      for( i = 0 ; i < 50; i++ )
      {
      fifty[i] = rand();
      }
      for( i = 0; i < 50; i++ )
      {
      printf( "%d\n", fifty[i] );
      }
      getchar();
      return 0;
      }
3
Contributors
5
Replies
6
Views
10 Years
Discussion Span
Last Post by patsfan4878
0

Thank you for not reading the "how to post code" thread at the top of the forum, and generally ignoring the watermark at the back of the edit window :icon_rolleyes:

0

Hey all, back once again. I've got some more code that i need some help with. Thanks to Aia for his help as well. Anywho this time I've still got the fifty random integers and now I'm working on sorts. I've managed to complete the bubblesort portion of the book but the Qsort is still giving me a bit of an issue. Basically i need to take what i have, print the fifty randoms, sort them and then print them once sorted. Any help as usual would be greatly appreciated.

  #include <stdio.h>
  #include <stdlib.h>
  #include <time.h>
  int main( void )
  {
  int fifty[50];
  int i;
  srand( (unsigned ) time( NULL ) );
  for( i = 0 ; i < 50; i++ )
  {
  fifty[i] = rand();
  }
  for( i = 0; i < 50; i++ )
  {
  printf( "%d\n", fifty[i] );
  }
  getchar();
  return 0;
  }

Edited by mike_2000_17: Fixed formatting

0

my bad man, didn't realize it was such a big deal, no need to be hostile. sorry.

0

my bad man, didn't realize it was such a big deal, no need to be hostile. sorry.

Next code you post do the same thing you did last, but write (code=c)
instead of (code). That would set the proper formatting for c code.

You posted the same code that I gave you as an example. You haven't done anything to it. You are asking for help about Qsort.
Please, post any tries that you have done by yourself using that type of sorting. Then, it is more likely that someone will help you.

Edited by mike_2000_17: Fixed formatting

0

Oops. This post was just a botch in general, but I ended up just having my compare function written incorrectly. Thanks for the input though.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.