【习题 3-3 UVA-1225】Digit Counting

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

水模拟

【代码】

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

int a[10];

int main()
{
	/*freopen("F:\rush.txt", "r", stdin);*/
	int T;
	scanf("%d", &T);
	while (T--)
	{
		int n;
		scanf("%d", &n);
		for (int i = 0; i <= 9; i++) a[i] = 0;
		for (int i = 1; i <= n; i++)
		{
			int x = i;
			while (x)
			{
				a[x % 10]++;
				x /= 10;
			}
		}
		for (int i = 0; i <= 9; i++)
		{
			printf("%d", a[i]);
			if (i == 9)
				puts("");
			else
				putchar(' ');
		}
	}
	return 0;
}
原文地址:https://www.cnblogs.com/AWCXV/p/7684120.html