文章

33

粉丝

0

获赞

149

访问

5.0k

头像
数字统计 题解:依旧C++语法
P1002 兰州大学机试题
发布于2026年3月16日 23:20
阅读数 83

#include<bits/stdc++.h>

using namespace std;

int main(){
	
	
	int l,r;
	while(cin>>l>>r){
	
	int count = 0;
	for(int i=l;i<=r;i++){
		string ss = to_string(i);
		
		for(int j = 0;j<ss.size();j++) if(ss[j]=='2') count++;
		
		}
		cout<<count<<endl;
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发