View Code of Problem 107

#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main() {
	int M, N;
	string s;
	int cnt[10];
	while (cin >> M >> N) {
		memset(cnt, 0, sizeof(cnt));
		for (int i = M; i <= N; ++i) {
			s = to_string(i);
			for (int j = 0; j < s.size(); ++j) {
				++cnt[s[j] - '0'];
			}
		}
		for (int i = 0; i < 10; ++i) {
			if (i != 0) {
				cout << " ";
			}
			cout << cnt[i];
		}
		cout << endl;
	}
}

Double click to view unformatted code.


Back to problem 107