文章

211

粉丝

1

获赞

1157

访问

47.6k

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

#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;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发