• + 0 comments

    My solution

    #include <stdio.h>
    #include <stdlib.h>
    
    int main() {
        char *s = (char*)malloc(1000*sizeof(char));
        int i=0,arr[10] = {0};
        
        scanf("%[^\n]",s);
        
        while(s[i] != '\0'){
            if((s[i] - '0')<=9) 
                arr[(s[i]- '0')]++;
            ++i;
        }
        
        for(i=0;i<=9;i++){
            printf("%d ", arr[i]);
        }
            
        return 0;
    }