ixxra

Untitled

Jan 30th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. const int ARRAY_SIZE = 15000000;
  6.  
  7.  
  8. int compare (const void* x1, const void* x2)
  9. {
  10.   return (*(int*) x1 - *(int*) x2);
  11. }
  12.  
  13. int main ()
  14. {
  15.   time_t now;
  16.   time (&now);
  17.  
  18.   srand (now);
  19.  
  20.   int* Big = (int*) malloc (ARRAY_SIZE * sizeof (int));
  21.   int i = 0;
  22.  
  23.   for (i = 0; i < ARRAY_SIZE; i++) {
  24.     Big[i] = rand ();
  25.   }
  26.  
  27.   printf ("sorting...\n");
  28.   qsort (Big, ARRAY_SIZE, sizeof (int), compare);
  29.   printf ("sorting done.\n");
  30.  
  31.   printf ("%d data sorted with quick sort.\n", ARRAY_SIZE);
  32.   return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment