|
#include <stdio.h>
int main( )
{
int ri,repeat;
int count;
long in;
int countdigit(long number, int digit);
scanf("%d",&repeat);
for(ri=1;ri<=repeat;ri++){
scanf("%ld",&in);
count=countdigit(in,2);
printf("count=%d\n",count);
}
}
int countdigit(long number, int digit)
{
int a,t,count,count1,i;
count=1; count1=0;
while((t=number/10)!=0)
count++;
for(i=1;i<=count;i++)
{a=number;
for(;a>0;a/=10)
{if(a%10==2)
count1++;}}
return count1;} |
|