Skip to content

Instantly share code, notes, and snippets.

@ashleyholman
Created February 28, 2013 09:48
Show Gist options
  • Save ashleyholman/5055567 to your computer and use it in GitHub Desktop.
Save ashleyholman/5055567 to your computer and use it in GitHub Desktop.
Here is the code to generate 1 million random integers for testing radixsort.c. Note that rand() will only output up to RAND_MAX which on my system is defined as 0x7fffffff, so I don't fully get the whole spectrum of possible 32 bit integers. I didn't bother fixing this, but perhaps 1 solution would be to generate two random 16-bit numbers and j…
#include <stdlib.h>
#include <stdio.h>
// Generate 1 million random 32-bit integers.
int main (int argc, char **argv) {
sranddev();
int i;
for (i = 0; i < 1000000; i++) {
unsigned x = (unsigned)rand();
printf("%i\n", x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment