Skip to content

Instantly share code, notes, and snippets.

@raphaelrk
Last active October 11, 2016 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raphaelrk/a258510f95a4fb62a5a0606053461795 to your computer and use it in GitHub Desktop.
Save raphaelrk/a258510f95a4fb62a5a0606053461795 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
void msort(int *arr, int n)
{
}
// tinyurl.com/oct11-cs-section
int main(void)
{
// fill msort_input with 10 random numbers, print them out
printf("before sort:\n");
srand(time(NULL));
int *msort_input = malloc(10 * sizeof(int));
for (int i = 0; i < 10; i++)
{
int r = rand();
msort_input[i] = r;
printf("%i ", r);
}
printf("\n");
// sort msort_input, print out result
msort(msort_input, 10);
printf("after sort:\n");
for (int i = 0; i < 10; i++)
{
printf("%i ", msort_input[i]);
}
printf("\n");
free(msort_input);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment