Skip to content

Instantly share code, notes, and snippets.

@yogurt1
Last active September 29, 2016 22:31
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 yogurt1/d4ae7e33f9dce3a4d2512ae194c476d2 to your computer and use it in GitHub Desktop.
Save yogurt1/d4ae7e33f9dce3a4d2512ae194c476d2 to your computer and use it in GitHub Desktop.
Sort from God, ANSI C version
#include <stdlib.h>
#include <stdio.h>
int main(void) {
int len;
scanf("%d", &len);
/* malloc array of ints */
int* arr = (int*)malloc(201 * sizeof(int));
for (int t, i = 0; i < len; i++) {
scanf("%d", &t);
arr[t+100]++;
}
for (int i = 0; i < 201; i++) {
for (int j = 0; j < arr[i]; j++) {
printf("%d ", i - 100);
}
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment