Last active
September 29, 2016 22:31
-
-
Save yogurt1/d4ae7e33f9dce3a4d2512ae194c476d2 to your computer and use it in GitHub Desktop.
Sort from God, ANSI C version
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 <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