public class TestDui { public static void main(String[] args) { //计数器的作用,统计数量 int count = 0; for(int i = 9999;i > 999;i--){ //注意从大到小的排列,所以从9999开始 int ge = i % 10; int shi = i / 10 % 10; int bai = i / 10 /10 %10; int qian = i / 1000; if(ge + bai == shi + qian){ System.out.print(i+" "); count++; if(count % 5 == 0){ System.out.println(); } } } System.out.println("满足条件的个数是:"+count); }}
原文地址:https://www.cnblogs.com/YRSWBY2016/p/12017499.html
时间: 2024-10-30 21:40:52