【C】#[NOIP2010]数字统计#
[NOIP2010]数字统计
https://www.nowcoder.com/practice/179d9754eeaf48a1b9a49dc1d438525a
#include <stdio.h> int num2(int L, int R) { int cnt = 0; for (int i = L; i <= R; i++) { int tmp = i; while (tmp) { if (tmp % 10 == 2) cnt++; tmp /= 10; } } return cnt; } int main() { int L, R; scanf("%d %d", &L, &R); printf("%d", num2(L, R)); return 0; }