package _2020_05_15;
public class ZuoYe {
//四叶玫瑰数是指四位数各位上的数字的四次方之和等于本身的数。
//要求找出所有的四叶玫瑰数
public static void main(String[] args){
for (int a = 1; a <10 ; a++) {//千位
for (int b = 0; b <10 ; b++) {//百位
for (int c = 0; c <10 ; c++) {//十位
for (int d = 0; d <10 ; d++) {//个位
if(a1000+b100+c10+d==aaaa+bbbb+cccc+ddd*d)//题目要求
System.out.println(“千位”+":"+a+“百位”+":"+b+“十位”+":"+c+“个位”+":"+d);
}
}
}
}
}
}
或者
public class ZuoYe2 {
//四叶玫瑰数是指四位数各位上的数字的四次方之和等于本身的数。
//要求找出所有的四叶玫瑰数
public static void main(String[] args) {
for (int i = 1000; i <10000 ; i++) {
int thousand = i/1000;//千位
int hundred = i%1000/100;//百位
int decade = i%100/10;//十位
int theUnit = i%10;//个位
//System.out.println(thousand);
if(thousandthousandthousandthousand
+hundredhundredhundredhundred
+decadedecadedecadedecade
+theUnittheUnittheUnittheUnit==i){
System.out.println(i);
}
}
}
}