要求:
1.定义一个方法,按照从大到小的顺序输出四位数中的个位+百位=十位+千位 的数字及个数
2.每行输出5个满足条件的数,之间用空格分隔
3.如:9999 9988 9977 9966 9955
public class Test {
public static void main(String[] args) {
int count = 0;
for (int i = 9999; i >= 1000; i--) {
int ge = i % 10;
int shi = i / 10 % 10;
int bai = i / 10 / 10 % 10;
int qian = i / 10 / 10 / 10 % 10;
if (ge + bai == shi + qian) {
System.out.print(i + " ");
count++;
while (count % 5 == 0) {
System.out.println();
break;
}
}
}
System.out.println("共有" + count + "个");
}
}