Java高级语言程序设计

编程实现:输出百位的数字、十位上的数字和个位数的数字和是25的三位数有多少个,具体有哪些

6个

public class A {
    public static void main(String[] args) {

        for (int i = 100; i < 1000; i++) {
            int a = i % 10;
            int b = i / 10 % 10;
            int c = i / 100;
            if (a + b + c == 25) {
                System.out.println(i);
            }
        }
    }
}


public class Test {

    public static void main(String[] args) {
        for (int i = 100; i < 1000; i++) {
            int hun = i / 100;
            int bt = i % 100 / 10;
            int sin = i % 10;
            if (hun + bt + sin == 25) {
                System.out.println(i + " ");
            }
        }
    }
}