Last active
October 11, 2016 18:49
-
-
Save raphaelrk/a258510f95a4fb62a5a0606053461795 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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