View Code of Problem 107

#include<string>
#include<iostream>
using namespace std;
int main(){
	int N,M;
	int a[12];
	while(cin>>N>>M){
		for(int i=0;i<10;i++){
			a[i]=0;
		}
		for(int i=N;i<=M;i++){
			string s=to_string(i);
			for(int i=0;i<s.length();i++){
				  int x=s[i]-'0';
				  a[x]++;	
			}
		}
		for(int i=0;i<10;i++){
			if(i==9){
				cout<<a[i]<<endl;
			}
			else{
				cout<<a[i]<<' ';
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 107