Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- const int ARRAY_SIZE = 15000000;
- int compare (const void* x1, const void* x2)
- {
- return (*(int*) x1 - *(int*) x2);
- }
- int main ()
- {
- time_t now;
- time (&now);
- srand (now);
- int* Big = (int*) malloc (ARRAY_SIZE * sizeof (int));
- int i = 0;
- for (i = 0; i < ARRAY_SIZE; i++) {
- Big[i] = rand ();
- }
- printf ("sorting...\n");
- qsort (Big, ARRAY_SIZE, sizeof (int), compare);
- printf ("sorting done.\n");
- printf ("%d data sorted with quick sort.\n", ARRAY_SIZE);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment