文章

211

粉丝

1

获赞

1223

访问

164.4k

头像
数字统计 题解:
P1002 兰州大学机试题
发布于 2026年3月
阅读数 410

#include<bits/stdc++.h>
using namespace std;
int main(){
    int l,r;
	while(cin >> l >> r){
		int cnt = 0;
		for(int i=l;i<=r;i++){
			string str = to_string(i);
			for(auto it:str){
				if(it == '2')	
					cnt++;
			}
		}
		cout << cnt << endl;
	}	
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发