题目传送门

总结

1、用桶计数,适合数量不多的场景,比如本题,就是记录\(0 \sim 9\)
2、考查数位分离

#include <bits/stdc++.h>

using namespace std;
const int N = 11;
int a[N];

int main() {
    int m, n;
    cin >> m >> n;
    for (int i = m; i <= n; i++) {
        int t = i;
        while (t) {
            int c = t % 10;
            a[c]++;
            t /= 10;
        }
    }
    for (int i = 0; i <= 9; i++)cout << a[i] << " ";
    return 0;
}

相关文章:

  • 2021-09-16
  • 2021-12-13
  • 2021-05-20
  • 2021-10-09
  • 2021-10-19
  • 2021-12-21
  • 2021-11-22
  • 2021-12-24
猜你喜欢
  • 2022-12-23
  • 2022-02-20
  • 2022-12-23
  • 2021-12-17
  • 2021-08-21
  • 2021-11-02
  • 2021-06-12
相关资源
相似解决方案