-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Digit_Frequency_Calculator.c
43 lines (40 loc) · 1.01 KB
/
Digit_Frequency_Calculator.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
char len[1000];
int num=0,flag[10]={0,0,0,0,0,0,0,0,0,0};
scanf("%s",len);
num=strlen(len);
for(int i=0;i<num;i++){
switch(len[i]){
case '0':flag[0]=flag[0]+1;
break;
case '1':flag[1]=flag[1]+1;
break;
case '2':flag[2]=flag[2]+1;
break;
case '3':flag[3]=flag[3]+1;
break;
case '4':flag[4]=flag[4]+1;
break;
case '5':flag[5]=flag[5]+1;
break;
case '6':flag[6]=flag[6]+1;
break;
case '7':flag[7]=flag[7]+1;
break;
case '8':flag[8]=flag[8]+1;
break;
case '9':flag[9]=flag[9]+1;
break;
}
}
for(int i=0;i<10;i++){
printf("%d ",flag[i]);
}
printf("\n");
return 0;
}