从L到R
by tumu1t @ 2018-12-18 17:51:32
@[胡迪](/space/show?uid=122449) 学过循环结构吗?如果没学过的话先去学了再AC这题吧...
by StudyingFather @ 2018-12-18 17:52:07
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
int L,R,num=0;
cin>>L>>R;
for(int i=L;i<=R;i++)
{
int tmp=i;
while(tmp){
num+=(tmp%10==2);
tmp/=10;
}
}
cout<<num;
return 0;
}
by CrTsIr @ 2018-12-18 18:54:05
@大佬们
小的知错了!求别骂。。。
还有,谢谢。
by 胡迪 @ 2018-12-19 12:50:04
@[xianhz](/space/show?uid=36215)
希望更丰富的展现?使用Markdown
```
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main() {
int L,R,num=0;
cin>>L>>R;
for(int i=L;i<=R;i++){
int tmp=i;
while(tmp){
num+=(tmp%10==2);
tmp/=10;
}
}
cout<<num;
return 0;
}
```
by 诱宵美⑨ @ 2018-12-30 19:32:57
qwq
by CrTsIr @ 2019-02-05 19:13:29
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
long long l,r,s,t,n;
int main()
{
scanf("%d%d",&l,&r);
for(int i=l;i<=r;i++)
{
s=i;
while(s!=0)
{
n=s%10;
if(n==2) t++;
s/=10;
}
}
printf("%d",t);
return 0;
}
by chen_zhe2 @ 2019-04-27 21:40:32
@[chen_zhe2](/space/show?uid=206122) 当心被封
by 伊卡洛斯之翼 @ 2019-05-10 17:28:00