HWOJ(练习用)挑7

2017-02-18  本文已影响0人  Yuu_CX
import java.util.*;
public class Main{
public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int number = findNumberOf1(scanner.nextInt());
            System.out.println(number);

        }

        public static int findNumberOf1(int num) {
            
            int count = 0;
            for(int i=1;i<num;i++){
                if(i%7==0||i%10==7||i/10%10==7||i/100%10==7||i/1000%10==7){
                    count++;
                }
            }
            
            return count;
        }
}
上一篇下一篇

猜你喜欢

热点阅读