View Code of Problem 107

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


int main() {
	int a, b;
	int num[15] = { 0 };
	while (cin >> a >> b) {
		if (a > b) {
			int temp = a;
			a = b;
			b = temp;
		}
		for (int i = a; i <= b; i++) {
			int t = i;
			while (t) {
				num[t % 10]++;
				t /= 10;
			}
		}
		for (int i = 0; i < 10; i++) {
			if (i!= 9) {
				cout << num[i] << " ";
			}
			else {
				cout << num[i] << endl;
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 107