Digit Frequency | HackerRank
Solution :
Develop by Samsus Salehin Sabbir
- #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 */
- int loop_1=0,count,count0,count1,count2,count3,count4,count5,count6,count7,count8,count9;
- char digit[1000];
- scanf("%s",&digit);
- count=count0=count1=count2=count3=count4=count5=count6=count7=count8=count9=0;
- while(digit[loop_1]!='\0'){
- if(digit[loop_1]=='0')
- count0++;
- else if(digit[loop_1]=='1')
- count1++;
- else if(digit[loop_1]=='2')
- count2++;
- else if(digit[loop_1]=='3')
- count3++;
- else if(digit[loop_1]=='4')
- count4++;
- else if(digit[loop_1]=='5')
- count5++;
- else if(digit[loop_1]=='6')
- count6++;
- else if(digit[loop_1]=='7')
- count7++;
- else if(digit[loop_1]=='8')
- count8++;
- else if(digit[loop_1]=='9')
- count9++;
- else
- count0 = count0;
- //printf("%d",count);
- loop_1++;
- }
- printf("%d %d %d %d %d %d %d %d %d %d\n",count0,count1,count2,count3,count4,count5,count6,count7,count8,count9);
- return 0;
- }
No comments