洛谷 P1554 C++简单题解

#include
using namespace std;
int main()
{
long long m, n, a[10] = { 0 },t,p;
cin >> m >> n;
for (int i = m; i <= n; i++)
{
p = i;
while(p!= 0)
{
t = p % 10;
for (int j = 0; j <= 9; j++)
{
if(t==j)
{
a[j]++;
}
}
p /= 10;
}
}
for(int i=0;i<=9;i++)
{
cout << a[i] << " ";
}
return 0;
}

你可能感兴趣的:(洛谷 P1554 C++简单题解)