public class HomeWork2 {
public static void main(String[] args) {
int count = 0;
for (int i = 9999; i >= 1000; i--) {
int qian = i / 1000;//求千位
int bai = i / 100 % 10;//求百位
int shi = i / 10 % 10;//求十位
int ge = i % 10;//求个位
if(ge + bai == shi + qian) {
System.out.print(i+" ");
count++;
if(count % 5 == 0) {
System.out.println();
}
}
}
}
}