diff --git a/C/Digit Frequency b/C/Digit Frequency new file mode 100644 index 0000000..d64bb4b --- /dev/null +++ b/C/Digit Frequency @@ -0,0 +1,16 @@ +int main() { + int* nums = (int*) malloc(10 * sizeof(int)); + char c; + + for(int i = 0; i < 10; i++) + *(nums+i) = 0; + + while(scanf("%c", &c) == 1) + if(c >= '0' && c <= '9') + (*(nums+(c-'0')))++; + + for(int i = 0; i < 10; i++) + printf("%d ", *(nums+i)); + + return EXIT_SUCCESS; +}