Skip to content

Instantly share code, notes, and snippets.

@yogurt1 yogurt1/sort_ansi.c
Last active Sep 29, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.