数字统计 题解:依旧C++语法
#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;
}
登录后发布评论
暂无评论,来抢沙发