class Practice02 {
public static void main(String[] args) {
int x;
int y;
int count = 0;
int gewei;
int shiwei;
int baiwei;
int qianwei;
int wanwei;
for(x = 10000; x <100000; x++ ) {
wanwei = x / 10000;
qianwei = (x - wanwei * 10000) / 1000;
baiwei = (x - wanwei * 10000 - qianwei * 1000) / 100;
shiwei = (x - wanwei * 10000 - qianwei * 1000 - baiwei * 100) / 10;
gewei = (x - wanwei * 10000 - qianwei * 1000 - baiwei * 100 - shiwei * 10);
if(gewei == wanwei) {
if(shiwei == qianwei) {
if(gewei + shiwei + qianwei + wanwei == baiwei){
count++;
System.out.println(x);
}
}
}
}
System.out.println("符合这样的数字一共有" + count + "个");
}
} |
|