洗澡

来源:互联网 发布:网络诈骗一千元 编辑:程序博客网 时间:2024/03/29 14:51

洗澡

时间限制:1000 ms  |  内存限制:65535 KB
难度:1
描述

Mostrp是个爱干净的好少年。 有一次去澡堂洗澡时发现 澡堂的澡柜编号中没有出现过数字‘4’。 Mostrp 感到很好奇。可能是因为在澡堂老板眼里。数字‘4’是十分不吉利的。

现在Mostrp知道澡柜的最大的编号N,你能帮他算出澡堂一共有多少澡柜吗?

输入
有多组数据,每行输入一个N。
( 1 <= N <= 50000 )
输出
输出澡柜的个数,输出占一行。
样例输入
35
样例输出
34

import java.util.Scanner;public class Main {public static boolean judge(int number) {while (number != 0) {if (number % 10 == 4) {return false;}number /= 10;}return true;}public static void main(String[] args) {Scanner scanner = new Scanner(System.in);while (scanner.hasNext()) {int number = scanner.nextInt();int count = 0;for (int i = 1; i <= number; i++) {if (judge(i)) {count++;}}System.out.println(count);}}}