传智杯-练习赛 A-1

传智杯-练习赛 A-1_第1张图片


import java.util.Scanner;
/**
 * @author zhang kun
 * @Classname code_1
 * @Description TODO
 * @Date 2020/12/4 20:24
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int count = 0;
        for(int j = 1; j <= N;j++){
            int sum = 0;
            int i = j;
            while(i!=0){
                if(sum >9){
                   break;
                }
                sum += i%10;
                i = i/10;
            }
            if(sum == 9){
                count++;
            }
        }
        System.out.println(count);
    }


}

你可能感兴趣的:(ACM传智杯,算法,ACM)