Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
47260 | zouqinghua | 数字统计 | C++ | Accepted | 1 MS | 260 KB | 398 | 2024-05-12 21:13:45 |
#include<bits/stdc++.h> int main() { int L,R; //定义区间 int i,count=0; scanf("%d %d",&L,&R); for(i=L;i<=R;i++) { int k=i; while(k) //对数字的每一位进行分析 { int temp=k%10; if(temp==2) count++; k/=10; } } printf("%d",count); return 0; }