数字统计 题解:
#include<stdio.h>
#include<stdlib.h>
int times;
void suan(int lll,int rrr){
times=0;
for(int i=lll;i<=rrr;i++){
int zanc=i;
while(zanc){
if(zanc%10==2){
times++;
}
zanc/=10;
}
}
}
int main(){
int l,r;
while(scanf("%d %d",&l,&r)!=EOF){
suan(l,r);
printf("%d\n",times);
}
}
登录后发布评论
暂无评论,来抢沙发