View Code of Problem 107

#include<stdio.h>
#include<string.h>
void main(){
  int num[10] = {0};
  int a,b,len;
  char temp[20];
  
  while(1){
    memset(num,0,sizeof(num));
    scanf("%d %d",&a,&b);
    for(int i=a;i<=b;i++){
      sprintf(temp,"%d",i);
      len = strlen(temp);
      for(int j=0; j<len; j++)
        num[temp[j]-'0']++;
    }
    for(int k=0;k<10;k++){
      if(k<9)
        printf("%d ",num[k]);
      else printf("%d",num[k]);
    }
    printf("\n");
  }
}

Double click to view unformatted code.


Back to problem 107