View Code of Problem 107

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int a[10];
	int m, n;
	while(cin >> m >> n)
	{
	    string s;
		memset(a, 0, sizeof(a));
		for(int i = m; i <= n; i++)
		{
			s = to_string(i);
			int len = s.size();
			for(int j = 0; j < len; j++)
			{
				a[s[j] - '0']++;
		    }
		}
		cout << a[0];
		for(int i = 1; i < 10; i++)
			cout << " " << a[i];
		cout << endl;
	}


	return 0;
}

Double click to view unformatted code.


Back to problem 107