1962 - Bathe

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

 Peter is a cleanly boy.One day,he finds  that  the  number of cabinet has not been the 

number '4'  when he goes to the bathhouse . Peter is curious about that .Maybe , in the
opinion of boss of bathhouse,  '4'  is a unlucky number .
  Now Peter knows the biggest number of the cabinet  N , can you help Peter to calculate
the amount of  cabinet in total?

题目输入

 The input contains many test cases . Each line has a positive integer N.

( 1 <= N <= 50000 )

题目输出

 For each test case, you should output one line . That is, Output the amount of  cabinet.

输入/输出样例

输入格式

3
5

输出格式

3
4

C语言解答

#include<stdio.h>
int main()
{
    int n,a,i,t,s,m;
    while(~scanf("%d",&n))
    {
        s=0;
        for(i=1;i<=n;i++)
        {
            t=i;a=1;
            while(t)
            {
                m=t%10;
                if(m==4)
                  {a=0;
                  break;}
                  t=t/10;
            }
            if(a!=0)
            s++;
        }
        printf("%d\n",s);
    }
    return 0;
}