42 lines
603 B
C
42 lines
603 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
#define NUM 10
|
||
|
|
||
|
void zero_arr(int *arr){
|
||
|
int i;
|
||
|
for (i = 0; i < NUM; i++){
|
||
|
arr[i] = 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void count_nums(char *input, int *count){
|
||
|
int i;
|
||
|
for ( i = 0; i < strlen(input); i++ ){
|
||
|
count[input[i] - '0']++;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
void print_arr(int *count){
|
||
|
int i;
|
||
|
for ( i = 0; i < NUM; i++ ){
|
||
|
printf("%d ", count[i]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main(){
|
||
|
int count[NUM];
|
||
|
|
||
|
char *input = malloc(1024 * sizeof *input);
|
||
|
scanf("%[^\n]", input);
|
||
|
input = realloc(input, strlen(input) + 1);
|
||
|
|
||
|
zero_arr(count);
|
||
|
count_nums(input, count);
|
||
|
print_arr(count);
|
||
|
|
||
|
return 0;
|
||
|
}
|