标签:
1 #include <stdio.h> 2 int main(int argc, char *argv[]) 3 { 4 int l,r,i; 5 int num=0; 6 int s; 7 freopen("two.in","r",stdin); 8 freopen("two","w",stdout); 9 scanf("%d%d",&l,&r); 10 11 for(i=l;i<=r;i++) 12 { 13 s=i; //s代表当前处理数 14 do 15 { 16 if((s%10)==2) //看个位是否为2 17 { 18 num++; 19 } 20 s=s/10; //将个位舍去 21 } 22 while(s>0); 23 } 24 printf("%d",num); 25 fclose(stdin); 26 fclose(stdout); 27 return 0; 28 }
标签:
原文地址:http://www.cnblogs.com/charlotteandxing/p/4684639.html